cz
A simple config utility for Nodejs
Table of contents
Quick start
const Cz = require('cz');
const config = new Cz();
config.load('./config.json');
config.defaults({
port: 4000
});
config.set('random', 'random value');
console.log('config', config.get());
console.log('db:host', config.get('db:host'));
console.log('mongodb://' + config.get('db:username') + ':' + config.get('db:password') + '@' + config.get('db:host') + ':' + config.get('db:port') + '/' + config.get('db:collection'));
console.log('mongodb://' + config.joinGets(['db:username', 'db:password', 'db:host', 'db:port', 'db:collection'], [':', '@', ':', '/']));
Status
![npm](https://img.shields.io/npm/v/cz.svg)
Documentation
Cz sets defaults()
as the most bottom object and applies all changes to the config object on top of that meaning anywhere in your app you can use config.defaults({})
to override the default values.
const config = require('cz');
config.defaults({
port: 4000,
logging: false
});
config.set('port', 5000);
config.get('port');
config.reset();
config.get('port');
To reset defaults just use config.defaults({});
To reset the config itself we provide config.reset();