Skip to content

Instantly share code, notes, and snippets.

@RB-Lab
Last active August 29, 2015 14:05
Show Gist options
  • Save RB-Lab/f9c807963fb2106ace71 to your computer and use it in GitHub Desktop.
Save RB-Lab/f9c807963fb2106ace71 to your computer and use it in GitHub Desktop.
index.js for node configs
var fs = require('fs');
var path = require('path');
var env = process.env.NODE_ENV || 'development';
var config = JSON.parse(fs.readFileSync(__dirname + '/'+env+'.json'));
config.env = env;
config.root = path.dirname(require.main.filename);
module.exports = config;
@RB-Lab
Copy link
Author

RB-Lab commented Aug 8, 2014

You just create a directory /config, add there this file and then you can add there configurations for different environment, such as development.json. Usage is pretty simple:

    var config = require('config');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment