Refactor client config (#529)

* Refactor client config

* Fix server tests

* Fix lint
This commit is contained in:
Charles Bochet
2023-07-07 11:10:42 -07:00
committed by GitHub
parent 11d18cc269
commit 26b033abc9
38 changed files with 386 additions and 180 deletions

View File

@ -8,8 +8,22 @@ import { StorageType } from './interfaces/storage.interface';
export class EnvironmentService {
constructor(private configService: ConfigService) {}
getDebugMode(): boolean | undefined {
return this.configService.get<boolean>('DEBUG_MODE')!;
isDebugMode(): boolean {
return this.configService.get<boolean>('DEBUG_MODE') ?? false;
}
isDemoMode(): boolean {
return this.configService.get<boolean>('DEMO_MODE') ?? false;
}
isTelemetryEnabled(): boolean {
return this.configService.get<boolean>('TELEMETRY_ENABLED') ?? true;
}
isTelemetryAnonymizationEnabled(): boolean | undefined {
return (
this.configService.get<boolean>('TELEMETRY_ANONYMIZATION_ENABLED') ?? true
);
}
getPGDatabaseUrl(): string {
@ -44,7 +58,7 @@ export class EnvironmentService {
return this.configService.get<string>('FRONT_AUTH_CALLBACK_URL')!;
}
getAuthGoogleEnabled(): boolean | undefined {
isAuthGoogleEnabled(): boolean | undefined {
return this.configService.get<boolean>('AUTH_GOOGLE_ENABLED');
}

View File

@ -16,12 +16,27 @@ import { IsAWSRegion } from './decorators/is-aws-region.decorator';
import { CastToBoolean } from './decorators/cast-to-boolean.decorator';
export class EnvironmentVariables {
// Stage
// Misc
@CastToBoolean()
@IsOptional()
@IsBoolean()
DEBUG_MODE?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
DEMO_MODE?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
TELEMETRY_ENABLED?: boolean;
@CastToBoolean()
@IsOptional()
@IsBoolean()
TELEMETRY_ANONYMIZATION_ENABLED?: boolean;
// Database
@IsUrl({ protocols: ['postgres'], require_tld: false })
PG_DATABASE_URL: string;