live-config

0.0.7 • Public • Published

live-config

Convention-based configuration

NPM Version Linux Build Test Coverage

TODO

  • Remove dependency on globals: CLIENT and DEVELOPMENT.
  • Move live-browser-config-requires-generated dependency to tmp.

Install

npm i -S live-config

Usage

Project structure

config
  default.js
  development.js
  production.js
modules
  foo
    index.js
    config
      default.js
      development.js
      production.js
  bar
    index.js
    config
      default.js
      development.js
      production.js
index.js
// config/default.js
module.exports = { 
  { foo: {key: '456'} } 
}
// modules/foo/config/default.js
module.exports = { 
  { {key: '123'} } 
}
import {config} from 'live-config'
 
config.get('foo.key') // 456

Scoped config.

import makeConfig from 'live-config'
 
const config = makeConfig('foo') 
 
config.get('key') // 456

Design

  • Root config overrides all other config.
  • Convention-based. Searches for a top-level config directory inside each module.
  • Modules set default configuration by environment.
  • A module's config is scoped to the module name from package.json.

Goals

  • Predictable. Conventions for location of config directories and module-name scoping makes it easy to trace resolved configuration.
  • Isomorphic. Works for Node.js and the browser.

License

MIT

Readme

Keywords

none

Package Sidebar

Install

npm i live-config

Weekly Downloads

8

Version

0.0.7

License

none

Last publish

Collaborators

  • vjpr