Add health check endpoint

This commit is contained in:
ngosang 2021-04-04 20:33:07 +02:00
parent f278c7cf8e
commit 757ec4358a

View File

@ -92,6 +92,16 @@ validateEnvironmentVariables();
createServer((req: IncomingMessage, res: ServerResponse) => {
const startTimestamp = Date.now()
// health endpoint. this endpoint is special because it doesn't print traces
if (req.url == '/health') {
res.writeHead(200, {
'Content-Type': 'application/json'
})
res.write(JSON.stringify({"status": "ok"}))
res.end()
return;
}
// count the request for the log prefix
log.incRequests()
log.info(`Incoming request: ${req.method} ${req.url}`)