Skip to content

tulehuynhnhat/nestjs-config

Repository files navigation

NestJS - Configuration

Introduction

Why create this project?

  • Know how to load and parse a .env file from the project root directory and merge key/value pairs from the .env file with environment variables assigned to process.env
  • Know how to use configuration (built-in Nest) to solve some problem

Project overview

Github: https://github.com/tulehuynhnhat/Nestjs-config
Node: 18.17.1
@nestjs/config: 3.0.0

Module & API

Setup after init project

Create .env file

ENV1=value_env1
ENV2=value_env2

Install package

npm i --save @nestjs/config

Situation

Situation 1: Import ConfigModule in App and get env from Something service

Situation 2: Import ConfigModule in App module set Global and get env from Something service

Situation 3: Get env from main

Situation 4: Custom configuration files

Situation 5: Use Config Service with interface as the type hint

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published