yacfg
v1.0.2
Published
yacfg organizes the configuration for different deployment environments.
Downloads
4
Maintainers
Readme
yacfg
yet another config
Introduction | Install | Quick Start | Options | Contribute
Introduction
yacfg
organizes the configuration for different deployment environments (e.g. production
, development
or test
). It takes care of merging, caching and freezing your configuration (see Options).
Goals
- Simple
- Fast
- Lightweight
- Tested
Install
npm i --save yacfg
Quick Start
Using the default behaviour
lib/bootstrap.js
var yacfg = require('yacfg');
// init the configuration once
yacfg.init();
// ...
routes/home.js
// use your config in each module you want
var config = require('yacfg').config;
module.exports = function home(req, res) {
res.send('Application "' + config.name + '" running');
};
Using your own config
module
lib/config.js
var yacfg = require('yacfg');
yacfg.init({
path: 'path/to/your/config-directory' // defaults to `process.cwd() + '/config'`
});
module.exports = yacfg.config;
Using your own environment sequence
Rule: production > staging > development > test
var yacfg = require('yacfg');
yacfg.init({
environment: 'development',
sequence: ['production', 'staging', 'development', 'test']
});
Options
Option | Description | Default
-------------- | ----------------------------------------------------------------------- | --------------------------
environment
| The current environment | process.env.NODE_ENV || 'production'
path
| The config base path | Defaults to <CWD>/config
sequence
| The sequence of your configuration e.g. production > development > test | ['production', 'development', 'test']
uncached
| Force a clean configuration | false
freeze
| Freezes the configuration | false
spec
| The tb
spec instance | null
Contribute
You want to help us? Cool, thanks!
It ist important to watch the given coding standards and to implement them.
At bottom it is very simple.
- Checkout of the repository.
- Run
npm i
. - Define the content and write some test for it.
- Implement the new functionality / resolve the bug.
- Run
gulp test
- Create a pull-request
License
The MIT License (MIT)
Copyright (c) 2014 - 2015 Marc Binder [email protected]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.