Skip to content

Instantly share code, notes, and snippets.

@rnjailamba
Created March 1, 2016 04:09
Show Gist options
  • Save rnjailamba/68a857e073f943799775 to your computer and use it in GitHub Desktop.
Save rnjailamba/68a857e073f943799775 to your computer and use it in GitHub Desktop.
Nodejs Expressjs Config file Development and Production - Service URL Mapping
module.exports = function(){
var userServiceURL;
var blogServiceURL;
var contentServiceURL;
switch(process.env.NODE_ENV || 'development'){// other option is export NODE_ENV=development in console
case 'development':
userServiceURL = "http://localhost:9000/userService/";
break;
case 'production':
userServiceURL = "http://"
break;
default:
}
return {
'userService.ping': userServiceURL+'ping',
};
};
var appConfig = require('../config/appConfig'); // configure service api urls in dev/prod/beta
var mappings = appConfig();
// PING
// ==============================================
router.get('/ping', function(req, res){
request(mappings['userService.ping'], function (error, response, body) {
if (!error && response.statusCode == 200) {
res.send(body);
}
})
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment