$ npm i --save @nestjs/config
// app.modules
import { Module } from '@nestjs/common';
import { ConfigModule } from '@nestjs/config';
@Module({
imports: [ConfigModule.forRoot()],
})
export class AppModule {}
// 전역적으로 설정
ConfigModule.forRoot({ isGlobal: true }),
// ex.service.ts
// standard constructor injection
constructor(private configService: ConfigService) {}
// get an environment variable
const dbUser = this.configService.get<string>('DATABASE_USER');