Node Simple Config
Purpose
Simplifies loading of configuration file. Other modules seem to over-complicate it. Inspired by Laravel
Installation
npm install node-simple-config
Features
- Loads configuration parameters in key-value manner
- Reloads configuration file
Usage
.env
ENV=DEV
LOG_LEVEL=DEBUG
DB_HOST_NAME=database.some-dns.myserver.com
DB_HOST_PORT=6379
DB_HOST_DATABASE=Users
DB_HOST_PASSWORD=passwerd
example.js
// Loads config file from .env filevar config = ; var dbHost = config;var dbPort = config; console; // database.some-dns.example.comconsole; // 6379 // Make changes to .env file// Say we change the DB_HOST_NAME=anotherhost.com in .env file config; var dbHost = config; console; // anotherhost.com
What if you don't have .env file?
You can either:
- Create a symlink
ln -s path/to/env .env
OR
- Start the application with config path as such
node yourApp.js --config-path=path/to/env
Test
npm test