@nod/configuration

0.1.0 • Public • Published

@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

/@nod/configuration/

    Package Sidebar

    Install

    npm i @nod/configuration

    Weekly Downloads

    0

    Version

    0.1.0

    License

    Apache-2.0

    Last publish

    Collaborators

    • old-nod
    • jacopkane