Skip to content

Instantly share code, notes, and snippets.

@naholyr naholyr/index.js
Created Sep 8, 2014

What would you like to do?
My usual nconf wrapper
"use strict";
Save as config/index.js
Config files =
- config/config.json
- config/config.$NODE_ENV.json
- config/config.$NODE_ENV.$USER.json
var path = require('path');
var fs = require('fs');
var conf = module.exports = require('nconf')
.defaults({NODE_ENV: 'production'});
var files = [
path.join(__dirname, 'config.json'),
path.join(__dirname, 'config.' + conf.get('NODE_ENV') + '.json'),
path.join(__dirname, 'config.' + conf.get('NODE_ENV') + '.' + conf.get('USER') + '.json')
console.log('Loading config from files', files);
conf.use('memory', {loadFrom: files});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.