Files
artcraft/packages/components/src/env/FakeYouFrontendEnvironment.ts
T

57 lines
1.4 KiB
TypeScript

enum Environment {
Development,
Staging,
Production,
}
export class FakeYouFrontendEnvironment {
static instance?: FakeYouFrontendEnvironment;
environment: Environment;
private constructor() {
switch (document.location.host) {
case "fakeyou.com":
this.environment = Environment.Production;
break;
case "staging.fakeyou.com":
this.environment = Environment.Staging;
break;
case "localhost:7000":
this.environment = Environment.Development;
break;
case "localhost:7001":
this.environment = Environment.Development;
break;
case "dev.fakeyou.com":
this.environment = Environment.Development;
break;
default:
this.environment = Environment.Production;
}
}
public static getInstance(): FakeYouFrontendEnvironment {
if (FakeYouFrontendEnvironment.instance === undefined) {
FakeYouFrontendEnvironment.instance = new FakeYouFrontendEnvironment();
}
return FakeYouFrontendEnvironment.instance;
}
public useProductionStripePlans(): boolean {
return this.isProduction() || this.isStaging();
}
public isProduction(): boolean {
return this.environment === Environment.Production;
}
public isStaging(): boolean {
return this.environment === Environment.Staging;
}
public isDevelopment(): boolean {
return this.environment === Environment.Development;
}
}