Created
March 1, 2016 04:09
-
-
Save rnjailamba/68a857e073f943799775 to your computer and use it in GitHub Desktop.
Nodejs Expressjs Config file Development and Production - Service URL Mapping
This file contains 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
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', | |
}; | |
}; |
This file contains 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 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