config module for nestjs using dotenv and jsyaml
npm install nestjs-configure --save or yarn add nestjs-configure
use .env or bootstrap.yml manage config
test=1
ip=localhost
# bootstrap.yml
this: is
a:
- YAML
- example
# config
{ this: 'is', a: [ 'YAML', 'example' ] }
import { Module } from '@nestjs/common';
import { ConfigModule } from 'nestjs-configure';
@Module({
imports: [ConfigModule.load()]
})
export class AppModule {
}
import { Injectable } from '@nestjs/common';
import { ConfigService } from 'nestjs-configure';
@Injectable()
class TestService {
constructor(private config: ConfigService) {}
getConfig() {
return this.config.getConfig();
}
}