mirror of
https://github.com/Tribufu/TribufuJS
synced 2026-08-09 21:01:06 +00:00
Fix circular dep
This commit is contained in:
parent
de1f90c622
commit
d743c1b53f
5 changed files with 47 additions and 61 deletions
|
|
@ -19,7 +19,7 @@ export class TribufuClient extends TribufuApi {
|
|||
private readonly clientSecret: string;
|
||||
|
||||
constructor(clientId: string, clientSecret: string) {
|
||||
super({});
|
||||
super();
|
||||
|
||||
this.clientId = clientId;
|
||||
this.clientSecret = clientSecret;
|
||||
|
|
@ -36,15 +36,16 @@ export class TribufuClient extends TribufuApi {
|
|||
* ```ts
|
||||
* // process.env.TRIBUFU_CLIENT_ID
|
||||
* // process.env.TRIBUFU_CLIENT_SECRET
|
||||
* const client = TribufuClient.fromEnv("TRIBUFU_");
|
||||
* const client = TribufuClient.fromEnv("TRIBUFU");
|
||||
* ```
|
||||
*/
|
||||
public static override fromEnv(prefix: string = ""): TribufuClient | null {
|
||||
const clientId = process.env[`${prefix}CLIENT_ID`];
|
||||
const clientSecret = process.env[`${prefix}CLIENT_SECRET`];
|
||||
public static override fromEnv(prefix?: string | null): TribufuClient | null {
|
||||
const envPrefix = prefix ? `${prefix}_` : "";
|
||||
const clientId = process.env[`${envPrefix}CLIENT_ID`];
|
||||
const clientSecret = process.env[`${envPrefix}CLIENT_SECRET`];
|
||||
|
||||
if (clientId && clientSecret) {
|
||||
return TribufuApi.withClient(clientId, clientSecret);
|
||||
return new TribufuClient(clientId, clientSecret);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue