Boilerplate Node.js Express REST JSON API Server
// app.js
/* in console run thus:
PORT=8009 node app.js
*/
const express = require('express')
const PORT = process.env.PORT || 8008
const startExpress = async () => {
const app = express()
app.use(express.json())
app.get('/', (req, res) => {
res.json(
{
'message': 'ok',
'routes': [
'/',
]
}
)
})
return app.listen(PORT, () => {
console.log({'process.env': process.env})
console.log(`App listening at https://SERVER:${PORT}`)
})
}
;(async () => {
await startExpress()
})()