Skip to content

Incremental config sequences for nodejs. Allows to get a combined config object from different sources

License

Notifications You must be signed in to change notification settings

Denrox/incremental-config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Installation

Requires nodejs >= 7.6

$ npm i incremental-config

Features

  • Combines configuration object from different sources
  • Supports YAML, JSON files and common JS objects
  • Allows to adjust priority of some config source by changing it's position in sequence

Examples

Here is a simple usage example:

$ npm i incremental-config
async function main() {
  let ic = require('incremental-config'),
    config = null;

  config = await ic([
    //following configuration source will have the lowest priority
    {
      type: 'json',
      source: {
        path: './test.json',
        charset: 'latin1'
      }
    },
    //higher priority for this one
    {
      type: 'yml',
      source: {
        path: './test.yml' //utf8 charset is applied when none specified
      }
    },
    //this source will have the highest priority.
    //it will override properties with same names from other sources
    {
      source: {
        testValue: 'someValue'
      }
    }
  ]);

  console.log(config);
}

main();

The result of this code will be a config object which has merged contents of all listed sources.

License

MIT

About

Incremental config sequences for nodejs. Allows to get a combined config object from different sources

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published