Skip to content
This repository has been archived by the owner on Feb 23, 2021. It is now read-only.

Latest commit

 

History

History
52 lines (36 loc) · 1.23 KB

README.md

File metadata and controls

52 lines (36 loc) · 1.23 KB

Neconfig examples

Description

Example of using the Neconfig module to configure a Nest application.

The AppModule registers NeconfigModule with hash reader for default values and with env reader to read from file and process.env. After that, in main.ts, you can get ConfigReader instance.

Install

git clone https://github.com/maximpyshko/neconfig-examples.git
cd neconfig-examples
npm i

Run

If you run the application just after installation, you could see that host and port are have the values by default:

$ npm start
> Listening on http://localhost:3000

Now, stop the application and in root of the project create a file with name .env. Add the following text to this file:

PORT = 4000

If you run now the application, you could see that application listening on port 4000:

$ npm start
> Listening on http://localhost:4000

But if you need override port without editing file, you can export environment variables before start application:

$ export PORT=5000
$ npm start
> Listening on http://localhost:5000

Or simply:

$ PORT=5000 npm start
> Listening on http://localhost:5000