Last active
March 24, 2018 08:59
-
-
Save thoughtspeed7/3ec4d0fcf8e3750988943a4360ba7512 to your computer and use it in GitHub Desktop.
Node.js Best Practices - Smarter Ways to Manage Config Files and Variables
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
// om namah shivay | |
// requires | |
const express = require('express'); | |
// environment variables | |
process.env.NODE_ENV = 'development'; | |
// uncomment below line to test this code against staging environment | |
// process.env.NODE_ENV = 'staging'; | |
// config variables | |
const config = require('./config/config.js'); | |
// module variables | |
const app = express(); | |
app.get('/', (req, res) => { | |
res.json(global.gConfig); | |
}); | |
app.listen(global.gConfig.node_port, () => { | |
console.log(`${global.gConfig.app_name} listening on port ${global.gConfig.node_port}`); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment