Skip to content

Instantly share code, notes, and snippets.

@jackhickey
Created June 21, 2018 10:34
Show Gist options
  • Save jackhickey/32d9a9fa04f8b9daac51ec64a956357e to your computer and use it in GitHub Desktop.
Save jackhickey/32d9a9fa04f8b9daac51ec64a956357e to your computer and use it in GitHub Desktop.
native nodejs health endpoint
const http = require('http');
const server = http.createServer((req, res) => {
if(req.url === '/health') {
res.setHeader('Content-Type', 'application/json');
res.end(new Buffer.from(JSON.stringify({status: 'UP'})));
} else {
res.statusCode = 404;
res.end('Not Found\n');
}
});
server.listen(3999);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment