nconf-jsonminify
v0.1.1
Published
A simple wrapper for nconf + jsonminify.
Downloads
4
Maintainers
Readme
nconf-jsonminify
A simple wrapper for nconf + jsonminify:
nconf: to read config data from various prioritized sources:
- Command-line arguments;
- Environment variables;
- Optional string or external file (JSON with optional comments).
jsonminify: to remove comments and whitespace within JSON string.
Install
npm install nconf-jsonminify
Usage
// import the module
var conf = require('nconf-jsonminify');
/*
* load from config directory
*/
// load: config/{NODE_ENV}.json or config/default.json
conf.load();
// load: config/{NODE_ENV}.json or config/default.json
conf.load('config');
// load: config/development.json
conf.load('config', 'development');
/*
* load from config file
*/
conf.loadFile('config/development.json');
conf.loadFile('config/testing.json');
conf.loadFile('config/staging.json');
conf.loadFile('config/production.json');
/*
* load from string
*/
conf.loadString('{ "users": [ "Alice", "Bob", "Carol" ] }');
/*
* obtain individual config item
*/
var host = conf.get('host');
var port = conf.get('port');
var users = conf.get('name');
//...
License
Licensed under the incredibly permissive MIT license.
Copyright © 2013+ William Yeh https://github.com/William-Yeh.