Files
sdk-js/src/singletion.ts
2025-05-27 08:11:22 -03:00

36 lines
775 B
TypeScript

// Copyright (c) Tribufu. All Rights Reserved.
// SPDX-License-Identifier: MIT
import { TribufuApi } from "./";
/**
* **Tribufu API**
*
* Helper class to get a singleton instance of the Tribufu API.
*/
export class TribufuApiSingleton {
private static instance: TribufuApi | null = null;
private constructor() {}
/**
* Get the singleton instance of {@link TribufuApi}.
*
* @return Singleton instance
*/
public static getInstance(): TribufuApi {
if (!this.instance) {
this.instance = TribufuApi.fromEnvOrDefault();
}
return this.instance;
}
/**
* Reset the singleton instance of {@link TribufuApi}.
*/
public static resetInstance() {
this.instance = null;
}
}