1.0.15 • Published 9 years ago
confo v1.0.15
confo - simple config file reader
Managing configs for different environments (based on NODE_ENV
variable) in js
or json
format.
How to use
- Install it with
npm install confo
Create a
confo.json
file in the same folder as the main entry point (usually project root). This file must contain aNODE_ENV: PATH
JSON object like this:{ "dev": "./config/environments/dev.js", "production": "./config/environments/production.js", "test": "./config/environments/test.js" }
Also you can set
CONFO_FILE
environment variable with full path toconfo.json
file.Create a config file. I prefer to write config files with
JavaScript
. It gives me the opportunity to use the language features like path joining or extending a base config. But you can useJSON
as well.var config = require('./base.js'); config.db.port = 28017; config.db.host = '127.0.0.1'; module.exports = config;
Just require
confo
and use it:var confo = require('confo'); console.log(confo.db.host);
That's all!
License
MIT