import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; @Injectable() export class EnvironmentService { constructor(private configService: ConfigService) {} getNodeEnv(): string { return this.configService.get('NODE_ENV', 'development'); } getAppUrl(): string { return ( this.configService.get('APP_URL') || 'http://localhost:' + this.getPort() ); } getPort(): number { return parseInt(this.configService.get('PORT', '3000')); } getAppSecret(): string { return this.configService.get('APP_SECRET'); } getDatabaseURL(): string { return this.configService.get('DATABASE_URL'); } getRedisUrl(): string { return this.configService.get( 'REDIS_URL', 'redis://localhost:6379', ); } getJwtTokenExpiresIn(): string { return this.configService.get('JWT_TOKEN_EXPIRES_IN', '30d'); } getStorageDriver(): string { return this.configService.get('STORAGE_DRIVER', 'local'); } getAwsS3AccessKeyId(): string { return this.configService.get('AWS_S3_ACCESS_KEY_ID'); } getAwsS3SecretAccessKey(): string { return this.configService.get('AWS_S3_SECRET_ACCESS_KEY'); } getAwsS3Region(): string { return this.configService.get('AWS_S3_REGION'); } getAwsS3Bucket(): string { return this.configService.get('AWS_S3_BUCKET'); } getAwsS3Endpoint(): string { return this.configService.get('AWS_S3_ENDPOINT'); } getAwsS3Url(): string { return this.configService.get('AWS_S3_URL'); } getMailDriver(): string { return this.configService.get('MAIL_DRIVER', 'log'); } getMailHost(): string { return this.configService.get('MAIL_HOST'); } getMailPort(): number { return parseInt(this.configService.get('MAIL_PORT')); } getMailUsername(): string { return this.configService.get('MAIL_USERNAME'); } getMailPassword(): string { return this.configService.get('MAIL_PASSWORD'); } getMailFromAddress(): string { return this.configService.get('MAIL_FROM_ADDRESS'); } getMailFromName(): string { return this.configService.get('MAIL_FROM_NAME'); } getPostmarkToken(): string { return this.configService.get('POSTMARK_TOKEN'); } isCloud(): boolean { const cloudConfig = this.configService .get('CLOUD', 'false') .toLowerCase(); return cloudConfig === 'true'; } isSelfHosted(): boolean { return !this.isCloud(); } }