mirror of
https://github.com/tribufu/tribufu-js
synced 2026-06-01 09:42:36 +00:00
Add more methods and singleton
This commit is contained in:
parent
962a3de36a
commit
009dfc04ab
4 changed files with 885 additions and 74 deletions
|
|
@ -66,7 +66,7 @@ export abstract class TribufuApiBase {
|
|||
*/
|
||||
protected static defaultHeaders(): HttpHeaders {
|
||||
const headers = {};
|
||||
headers["X-Tribufu-Language"] = "javascript";
|
||||
headers["X-Tribufu-Library"] = "javascript";
|
||||
headers["X-Tribufu-Version"] = TRIBUFU_VERSION;
|
||||
return headers;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
23
src/api/singletion.ts
Normal file
23
src/api/singletion.ts
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
// Copyright (c) Tribufu. All Rights Reserved.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import { TribufuApi } from "./index";
|
||||
|
||||
/**
|
||||
* **Tribufu API**
|
||||
*
|
||||
* Helper class to get a singleton instance of the Tribufu API.
|
||||
*/
|
||||
export class TribufuApiSingleton {
|
||||
private static INSTANCE: TribufuApi | null = null;
|
||||
|
||||
private constructor() {}
|
||||
|
||||
public static getInstance(): TribufuApi {
|
||||
if (!TribufuApiSingleton.INSTANCE) {
|
||||
TribufuApiSingleton.INSTANCE = TribufuApi.fromEnvOrDefault();
|
||||
}
|
||||
|
||||
return TribufuApiSingleton.INSTANCE;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue