Environment sensitive configuration file loader for node.js
npm install cfEnvironment sensitive config loader for node.js, using xtend
Installation:
npm install cf
Create a directory where you intend to store your configuration files. Eg. 'config'. In that
directory, make two files:
- config/default.config.json
- config/development.config.json
In your code:
``javascript`
var myConfig = require('cf')({
root: __dirname + '/config'
});
Now your myConfig variable will be an object containing all the values of the default
config file and the ones your development config file overrides.
Now you can also make a production config in config/production.config.json and whenNODE_ENV=production node myapp.js
you start your app using that file will
be used instead.
- root: root directory of your config files. Requiredsuffix
- : what file suffix you want to use.. default is .config.jsondefaultEnv`: what environment name to use if none is defined.
-
MIT