live-config
v0.0.7
Published
<h1 align="center"> <img src="https://cdn.rawgit.com/live-js/live-config/master/logo.svg" alt="live-config"> </h1>
Downloads
13
Readme
Convention-based configuration
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.