Skip to content

Instantly share code, notes, and snippets.

@cristoni
Created November 10, 2018 11:36
Show Gist options
  • Save cristoni/c0c591ce024580fbdd965b41a9664dd0 to your computer and use it in GitHub Desktop.
Save cristoni/c0c591ce024580fbdd965b41a9664dd0 to your computer and use it in GitHub Desktop.
Config module for NestJS
import { Module } from '@nestjs/common';
import { ConfigService } from './config.service';
@Module({
providers: [
{
// Load the service as a provider
provide: ConfigService,
// Tells the service which file to load upon initialization
useValue: new ConfigService(`${process.env.NODE_ENV || 'development'}.env`),
},
],
// Expose it to any other module it implement it
exports: [ConfigService],
})
export class ConfigModule {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment