[develop | DONE | ADDED] add /health-check method
This commit is contained in:
parent
72f1f8c5be
commit
159a175089
24
server.ts
24
server.ts
|
@ -198,6 +198,30 @@ export function app() {
|
|||
buildCss(req.params.id, req.params.suffix, variables);
|
||||
res.status(200).send({code: 200, message: 'CSS build for ' + req.params.id + ' layout was successful'});
|
||||
});
|
||||
server.get('/health-check', async (_req, res, _next) => {
|
||||
var uptime = process.uptime();
|
||||
const date = new Date(uptime*1000);
|
||||
const days = date.getUTCDate() - 1,
|
||||
hours = date.getUTCHours(),
|
||||
minutes = date.getUTCMinutes(),
|
||||
seconds = date.getUTCSeconds(),
|
||||
milliseconds = date.getUTCMilliseconds();
|
||||
|
||||
|
||||
const healthcheck = {
|
||||
uptime: days + " days, " + hours + " hours, " + minutes + " minutes, " + seconds + " seconds, " + milliseconds + " milliseconds",
|
||||
message: 'OK',
|
||||
timestamp: new Date()
|
||||
};
|
||||
try {
|
||||
res.send(healthcheck);
|
||||
} catch (error) {
|
||||
healthcheck.message = error;
|
||||
res.status(503).send();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Example Express Rest API endpoints
|
||||
// server.get('/api/**', (req, res) => { });
|
||||
// Serve static files from /browser
|
||||
|
|
Loading…
Reference in New Issue