Deep-conf
Configuration library for Node.js application server deployments. It lets you define a set of configs with inheritance.
Quick Start
Install it with NPM or add it to your package.json:
$ npm install deep-conf
Then:
// Create instance by factoryvar configBuilder = ; // Register new config with name "sampleConfig"configBuilder; // Get registered config by namevar config = configBuilder; console;// localhost 80 http://localhost:80
API
register: create new config with name and optional parent. NOTE: field info, that contains name and parentName, will be added to config, so do not add to your config field with this name, because it will be overrided.
// Register new config with name "development"configBuilder; // Register new config with name "production",// inherite it from "development"// and replace field "host" with new valueconfigBuilder;
update: update existing config
// Update fields of existing config "development"configBuilder;
get: get registered config
// Get config "production"var config = configBuilder; console;// example.com 80
func: define in config functional field
// Register config with functional fieldconfigBuilder; var config = configBuilder; console;// 3
stringify: get registered config as string with optional space count (like JSON.stringify)
// Register config "stringConfig"configBuilder; // Stringify config "stringConfig"var str = configBuilder; console;// {// "host": "localhost",// "port": 80,// "fullName": "http://localhost:80",// "sum": function (a, b) {var sum = a + b;return sum;}// }
ConfigBuilder: create instance with constructor
var configBuilder = new ConfigBuilder;