Skip to content

Instantly share code, notes, and snippets.

@mousetree
Created July 11, 2018 09:15
Show Gist options
  • Save mousetree/72fc4c6331cdccef46ac3a2190bb5c30 to your computer and use it in GitHub Desktop.
Save mousetree/72fc4c6331cdccef46ac3a2190bb5c30 to your computer and use it in GitHub Desktop.
Node.js server showing environment variables
const express = require('express')
const app = express()
/*
For the purpose of making the testing easier, we've just put this
in a seperate file.
*/
const myLib = require('./lib')
const commitRef = process.env.APP_COMMIT_REF || 'N/A'
const buildDate = process.env.APP_BUILD_DATE || new Date().toISOString()
app.get('/', (req, res) => {
const welcome = myLib.helloWorld()
const text = `${welcome}! We're at commit ${commitRef} which was built at ${buildDate}`
res.send(text)
})
app.listen(3000, () => console.log('Example app listening on port 3000!'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment