UNPKG

generator-chek-ms

Version:

boilerplate de creación de microservicios en Chek

29 lines (23 loc) 724 B
import { Injectable } from '@nestjs/common'; import { ConfigService } from '@nestjs/config'; import { Environment } from './environment'; @Injectable() export class EnvironmentService { constructor( private readonly configService: ConfigService<Environment, true>, ) {} getEnvironmentValue<Key extends keyof Environment>( key: Key, ): Environment[Key] { return this.configService.getOrThrow(key); } get isSwaggerEnabled(): boolean { return this.configService.getOrThrow('ENABLE_SWAGGER'); } get isProd(): boolean { return this.configService.getOrThrow('NODE_ENV') === 'production'; } get isTest(): boolean { return this.configService.getOrThrow('NODE_ENV') === 'test'; } }