Skip to content

Instantly share code, notes, and snippets.

@DinoChiesa
Created June 20, 2018 16:23
Show Gist options
  • Save DinoChiesa/ec37fc48c7ca169601acd3d52c811b85 to your computer and use it in GitHub Desktop.
Save DinoChiesa/ec37fc48c7ca169601acd3d52c811b85 to your computer and use it in GitHub Desktop.
nodejs hello world
const app = require('express')(),
bodyParser = require('body-parser'),
yes = require('yes-https'); // HSTS => https always
var gStatus = {
version : '20180619-1845'
};
// HSTS on only if process.env.NODE_ENV == 'production'
app.use(yes());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.get('/status', function(request, response) {
...
});
...
const port = process.env.PORT || 5950;
const server = app.listen(port, function() {
log.setLevel(3);
log.write(0, "service version %s listening on port %s", gStatus.version, server.address().port);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment