rk-config

2.0.6 • Public • Published

rk-config

Build Status Coverage Status

An environment-aware config system.

Features

  • Multiple data source.
  • Deep override.
  • Rewrite config.
  • Support interpolation: ES6 string template, Javascript value

Examples

 let fileSource = new JsonConfigProvider('path/to/config.json');
 let config = new ConfigLoader(fileSource);
 await config.load_()...;

 let dbSource = new DbConfigProvider(config.data.dbConnection);
 config.provider = dbSource;
 await config.reload_()...;

 // same as: let envAwareLoader = new ConfigLoader(
 //    new (EnvAwareConfigProviderF('.json', JsonConfigProvider, 'default'))('config/dir', 'app', 'production')
 // );
 let envAwareLoader = ConfigLoader.createEnvAwareJsonLoader('config/dir', 'app', 'production');
 
 // Loader will load config/dir/app.default.json first, 
 // and then load config/dir/app.production.json, 
 // and finally override the default.
 let cfg = await envAwareLoader.load_(); 

License

MIT

Dependencies (0)

    Dev Dependencies (7)

    Package Sidebar

    Install

    npm i rk-config

    Weekly Downloads

    8

    Version

    2.0.6

    License

    MIT

    Unpacked Size

    13.3 kB

    Total Files

    7

    Last publish

    Collaborators

    • rockie