subsystem-config v0.1.0
subsystem-config
An opinionated configuration subsystem for Node.js applications.
This subsystem is merely a wrapper around node-etc
providing the following default loading behaviour (each subsequent step overloads any previous
configuration):
1. application land defaults via config.<operation>
2. <app_root>/etc
folder
3. <app_root>/config/default.yaml
file
4. <app_root>/config/<NODE_ENV>.yaml
file
5. /etc/<app_name>
folder
6. ENVIRONMENT variables via <app_name>_path_to_cofig
7. command-line config files via -c
or --config
arguments
8. command-line arguments via --path:to:config
arguments
NOTES:
-
inside<app_name>
will be replaced with_
NODE_ENV
also support multiple files via a,
separator. i.e. you can load multiple files by usingNODE_ENV=development,unit-test
Installation
npm install --save subsystem-config
Usage
To setup this subsystem and retrieve your configuration:
const config = require('subsystem-config');
console.log(config.toJSON());
console.log(config.get('path:to:config'));
As this package is just a wrapper around node-etc. Any operations that node-etc supports are available on the exposed config object. Thus you can also load configuration using something like this:
const config = require('subsystem-config');
config.folder('path/to/config/folder');
config.file('path/to/config/file.yaml');
License
6 years ago