Created
October 15, 2018 12:21
-
-
Save vinaymavi/483300b4d758c4392aa70f4033c8f8be to your computer and use it in GitHub Desktop.
Node.js configuration management example index.js file.
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
// 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