0.1.0 • Published 8 years ago

@nod/configuration v0.1.0

Weekly downloads
1
License
Apache-2.0
Repository
github
Last release
8 years ago

@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.

GitHub tag Build status Dependency Status Join the chat

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:

Send e-mail Join the chat

forthebadge by NOD studios