Created
July 18, 2020 07:58
-
-
Save darwinsubramaniam/13d64b7794da8be9dc3928561429709d to your computer and use it in GitHub Desktop.
NestJs Config , Loading different Env File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Module } from '@nestjs/common'; | |
import { ConfigModule } from '@nestjs/config'; | |
import { join } from 'path'; | |
require('dotenv').config(); | |
@Module({ | |
imports: [ | |
ConfigModule.forRoot({ | |
envFilePath: process.env.APP_ENV === 'dev' ? | |
join(process.cwd(), 'environment', 'dev.env') : | |
join(process.cwd(), 'environment', 'prod.env'), | |
isGlobal: true, | |
}) | |
], | |
controllers: [], | |
providers: [], | |
}) | |
export class AppModule { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment