@ -4,6 +4,7 @@ import { ConfigService } from '@nestjs/config';
|
||||
|
||||
import { AwsRegion } from './interfaces/aws-region.interface';
|
||||
import { StorageType } from './interfaces/storage.interface';
|
||||
import { SupportDriver } from './interfaces/support.interface';
|
||||
|
||||
@Injectable()
|
||||
export class EnvironmentService {
|
||||
@ -103,14 +104,14 @@ export class EnvironmentService {
|
||||
}
|
||||
|
||||
getSupportDriver(): string {
|
||||
return this.configService.get<string>('SUPPORT_DRIVER') ?? 'front';
|
||||
return this.configService.get<string>('SUPPORT_DRIVER') ?? SupportDriver.None;
|
||||
}
|
||||
|
||||
getSupportFrontendKey(): string | null {
|
||||
return this.configService.get<string>('SUPPORT_FRONTEND_KEY') ?? null;
|
||||
getSupportFrontChatId(): string | undefined {
|
||||
return this.configService.get<string>('SUPPORT_FRONT_CHAT_ID');
|
||||
}
|
||||
|
||||
getSupportHMACKey(): string | null {
|
||||
return this.configService.get<string>('SUPPORT_HMAC_KEY') ?? null;
|
||||
getSupportFrontHMACKey(): string | undefined {
|
||||
return this.configService.get<string>('SUPPORT_FRONT_HMAC_KEY');
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,6 +16,7 @@ import { StorageType } from './interfaces/storage.interface';
|
||||
import { AwsRegion } from './interfaces/aws-region.interface';
|
||||
import { IsAWSRegion } from './decorators/is-aws-region.decorator';
|
||||
import { CastToBoolean } from './decorators/cast-to-boolean.decorator';
|
||||
import { SupportDriver } from './interfaces/support.interface';
|
||||
|
||||
export class EnvironmentVariables {
|
||||
// Misc
|
||||
@ -104,6 +105,19 @@ export class EnvironmentVariables {
|
||||
@IsString()
|
||||
@ValidateIf((env) => env.STORAGE_TYPE === StorageType.Local)
|
||||
STORAGE_LOCAL_PATH?: string;
|
||||
|
||||
// Support
|
||||
@IsEnum(SupportDriver)
|
||||
@IsOptional()
|
||||
SUPPORT_DRIVER?: SupportDriver;
|
||||
|
||||
@ValidateIf((env) => env.SUPPORT_DRIVER === SupportDriver.Front)
|
||||
@IsString()
|
||||
SUPPORT_FRONT_CHAT_ID?: AwsRegion;
|
||||
|
||||
@ValidateIf((env) => env.SUPPORT_DRIVER === SupportDriver.Front)
|
||||
@IsString()
|
||||
SUPPORT_FRONT_HMAC_KEY?: string;
|
||||
}
|
||||
|
||||
export function validate(config: Record<string, unknown>) {
|
||||
|
||||
@ -0,0 +1,4 @@
|
||||
export enum SupportDriver {
|
||||
None = 'none',
|
||||
Front = 'front',
|
||||
}
|
||||
Reference in New Issue
Block a user