@nod/configuration
v0.1.0
Published
Merges environment config, default properties, and runtime options.
Downloads
4
Readme
@nod/configuration
Merges environment config, default properties and runtime options.
You can add strict type checking for configuration object parameters with Merger class. See below for details.
Supports ES5, ES7, AMD, CommonJS, System and EcmaScript modules.
Usage:
Installation:
npm install --save @nod/configuration
Examples:
Usage :
import { Configuration } from '@nod/configuration';
process.env.DUMMY_TEST = 'works';
class ExampleConfiguration extends Configuration {
//add some default properties
example = true;
}
let config = new ExampleConfiguration({
example = false
};
console.log(config.example, config.dummy.test);
//outputs : false, 'works'
Typesafe :
import { Configuration, Merger } from '@nod/configuration';
import { param, returns, Optional as optional } from 'decorate-this';
class ExampleConfiguration extends Configuration {
//add some default properties
example = true;
dummy = 'should check this for string';
}
class ExampleMerger extends Merger {
@param(optional({
example : Boolean,
dummy : optional(String)
}))
@returns(Object)
setOptions(options = {}) {
return super.setOptions(options);
}
}
let config = new ExampleConfiguration({}, ExampleMerger);
Build and develop:
gulp
#will build and start watching for changes
or
npm run build
npm run watch
or
npm run default
Please check other available gulp tasks with:
gulp -T
TODO:
- Gulp tasks as another dependency
- More detailed inline docs
Support:
by NOD studios