Last active
March 14, 2020 01:38
-
-
Save gergelyke/daa4d2825a5066197e4a to your computer and use it in GitHub Desktop.
Configuration with a config.js file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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