Skip to content

Instantly share code, notes, and snippets.

@gergelyke
Last active March 14, 2020 01:38
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save gergelyke/daa4d2825a5066197e4a to your computer and use it in GitHub Desktop.
Configuration with a config.js file
var url = require('url');
var config = module.exports = {};
var redisToGoConfig;
config.server = {
host: '0.0.0.0',
port: process.env.PORT || 3000
};
// look, a comment in the config file!
// would be tricky in a JSON ;)
config.redis = {
host: 'localhost',
port: 6379,
options: {
}
};
if (process.env.REDISTOGO_URL) {
redisToGoConfig = url.parse(process.env.REDISTOGO_URL);
config.redis.port = redisToGoConfig.port;
config.redis.host = redisToGoConfig.hostname;
config.redis.options.auth_pass = redisToGoConfig.auth.split(':')[1];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment