mirror of
https://github.com/tribufu/sdk-js
synced 2025-06-16 18:44:18 +00:00
Generate code with openapi-generator (#5)
This commit is contained in:
35
src/singletion.ts
Normal file
35
src/singletion.ts
Normal file
@ -0,0 +1,35 @@
|
||||
// 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user