mirror of
https://github.com/tribufu/sdk-js
synced 2025-06-16 18:44:18 +00:00
Add more methods and singleton
This commit is contained in:
@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user