Skip to content

Instantly share code, notes, and snippets.

@vinaymavi
Created October 15, 2018 12:21
Show Gist options
  • Save vinaymavi/483300b4d758c4392aa70f4033c8f8be to your computer and use it in GitHub Desktop.
Save vinaymavi/483300b4d758c4392aa70f4033c8f8be to your computer and use it in GitHub Desktop.
Node.js configuration management example index.js file.
// Load .env file
require('dotenv').config()
const express = require('express');
const config = require('./src/config')
const app = express();
const port = process.env.PORT || 3000
app.get("*",(req,res)=>{
res.setHeader("Content-Type","application/json")
res.send(JSON.stringify(config));
res.end();
})
app.listen(port,()=>{
console.log(config.message,"PORT",port);
console.log("FULL CONFIG")
console.log(config);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment