@component-tree/config
v1.0.0
Published
A lightweight configuration loader. Easily and uniformly access environment, command line or JSON variables throughout your application.
Downloads
1
Readme
@component-tree/config
A lightweight configuration loader
Overview
Easily and uniformly access environment, command line or JSON variables throughout your application.
The JSON configuration is loaded from the path set by CONFIG_FILE
environment variable. The default location, if CONFIG_FILE
is not set, will be conf/default.json
Ideally in a production envionment you would provide a path like /etc/your-app/config.json
.
Configuration file is optional
If there is no config file found, you can still access your environment and command-line variables.
Install
npm install i -S @component-tree/config
Test
npm test
Usage
Example default.json
{
"app": "Super Deluxe App",
"redis": {
"host": "127.0.0.1",
"port": 6379,
},
"something": {
"nested": "this-way-comes"
}
}
const config = require('@component-tree/config');
const redisSettings = config.get('redis');
const redis = new Redis(redisSettings);
const something= config.get('something');
console.log(something.nested);
License
MIT