confo

1.0.15 • Public • Published

confo - simple config file reader

img img img img img img

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 a NODE_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 to `confo.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 use JSON 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

Package Sidebar

Install

npm i confo

Weekly Downloads

2

Version

1.0.15

License

MIT

Last publish

Collaborators

  • ssbb