Environment, command line or JSON file with comments and single quotes
Wanted multiple tiered config like config https://github.com/lorenwest/node-config will use NODE_ENV
and ALCE parsing like getconfig with the added ability to define config.json
directory or filename via command line --config
or environment variable NODE_CONFIG_DIR
npm install config4u
{
postgres: {
"url": '...', // database connection url
}
}
config = new require('config4u')({ default: "values"})
dburl = config.postgres.url
node myapp.js --config dir_or_filename // /somepath for /somepath.config.json or dev_config.json for /current_dir/dev_config.json
- Passed in defaults
config.json
file (in current application directory if not defined by--config
)config.json
file (as defined by--config
)config.json
file (optionally if defined byNODE_CONFIG_DIR
)NODE_ENV
environment value as JSON string, ex:NODE_ENV = "{postgres: {url: '...'}}"
๐ Feedback, problem reports, enhancement requests are welcome.
๐ Example code are better.
๐ Pull requests are best.