/* eslint-disable @typescript-eslint/no-non-null-assertion */ import { Injectable, LogLevel } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { AwsRegion } from './interfaces/aws-region.interface'; import { StorageType } from './interfaces/storage.interface'; import { SupportDriver } from './interfaces/support.interface'; import { LoggerDriver } from './interfaces/logger.interface'; @Injectable() export class EnvironmentService { constructor(private configService: ConfigService) {} isDebugMode(): boolean { return this.configService.get('DEBUG_MODE') ?? false; } isSignInPrefilled(): boolean { return this.configService.get('SIGN_IN_PREFILLED') ?? false; } isTelemetryEnabled(): boolean { return this.configService.get('TELEMETRY_ENABLED') ?? true; } isTelemetryAnonymizationEnabled(): boolean { return ( this.configService.get('TELEMETRY_ANONYMIZATION_ENABLED') ?? true ); } isFlexibleBackendEnabled(): boolean { return this.configService.get('FLEXIBLE_BACKEND_ENABLED') ?? false; } getPort(): number { return this.configService.get('PORT') ?? 3000; } getPGDatabaseUrl(): string { return this.configService.get('PG_DATABASE_URL')!; } getFrontBaseUrl(): string { return this.configService.get('FRONT_BASE_URL')!; } getAccessTokenSecret(): string { return this.configService.get('ACCESS_TOKEN_SECRET')!; } getAccessTokenExpiresIn(): string { return this.configService.get('ACCESS_TOKEN_EXPIRES_IN') ?? '30m'; } getRefreshTokenSecret(): string { return this.configService.get('REFRESH_TOKEN_SECRET')!; } getRefreshTokenExpiresIn(): string { return this.configService.get('REFRESH_TOKEN_EXPIRES_IN') ?? '90d'; } getRefreshTokenCoolDown(): string { return this.configService.get('REFRESH_TOKEN_COOL_DOWN') ?? '1m'; } getLoginTokenSecret(): string { return this.configService.get('LOGIN_TOKEN_SECRET')!; } getLoginTokenExpiresIn(): string { return this.configService.get('LOGIN_TOKEN_EXPIRES_IN') ?? '15m'; } getFrontAuthCallbackUrl(): string { return ( this.configService.get('FRONT_AUTH_CALLBACK_URL') ?? this.getFrontBaseUrl() + '/verify' ); } isAuthGoogleEnabled(): boolean { return this.configService.get('AUTH_GOOGLE_ENABLED') ?? false; } getAuthGoogleClientId(): string | undefined { return this.configService.get('AUTH_GOOGLE_CLIENT_ID'); } getAuthGoogleClientSecret(): string | undefined { return this.configService.get('AUTH_GOOGLE_CLIENT_SECRET'); } getAuthGoogleCallbackUrl(): string | undefined { return this.configService.get('AUTH_GOOGLE_CALLBACK_URL'); } getStorageType(): StorageType { return ( this.configService.get('STORAGE_TYPE') ?? StorageType.Local ); } getStorageS3Region(): AwsRegion | undefined { return this.configService.get('STORAGE_S3_REGION'); } getStorageS3Name(): string | undefined { return this.configService.get('STORAGE_S3_NAME'); } getStorageLocalPath(): string { return ( this.configService.get('STORAGE_LOCAL_PATH') ?? '.local-storage' ); } getSupportDriver(): string { return ( this.configService.get('SUPPORT_DRIVER') ?? SupportDriver.None ); } getSupportFrontChatId(): string | undefined { return this.configService.get('SUPPORT_FRONT_CHAT_ID'); } getSupportFrontHMACKey(): string | undefined { return this.configService.get('SUPPORT_FRONT_HMAC_KEY'); } getLoggerDriver(): string { return ( this.configService.get('LOGGER_DRIVER') ?? LoggerDriver.Console ); } getLogLevels(): LogLevel[] { return ( this.configService.get('LOG_LEVELS') ?? [ 'log', 'error', 'warn', ] ); } getSentryDSN(): string | undefined { return this.configService.get('SENTRY_DSN'); } }