@brunost/nestjs-config-module

NestJS environment config utility module

Usage no npm install needed!

<script type="module">
  import brunostNestjsConfigModule from 'https://cdn.skypack.dev/@brunost/nestjs-config-module';
</script>

README

NestJS Environment Config Module

Installation

npm i -S @brunost/nestjs-config-module

Usage

This module expects there to exist an enviroment file in the root of the consuming projects folder.

If NODE_ENV is not set it will default to "development.env".

Example

development.env

WELCOME_MESSAGE="Hello World!"

app.module.ts

// root module
import { ConfigModule } from "@brunost/nestjs-config-module";

@Module({
  imports: [ConfigModule],
})
export class AppModule {}

app.service.ts

// consumer
import { ConfigService } from "@brunost/nestjs-config-module";

@Injectable()
export class AppService {

  constructor(
    private readonly config: ConfigService,
  ) {}

  public getHello(): string {
    return this.config.get("WELCOME_MESSAGE");
  }

}

License

Licensed under the MIT License - see the LICENSE file for details.