From 6bf4e91c70ce37deee6ddb8bb884d454b2254496 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Mon, 4 Dec 2023 11:14:36 +0000 Subject: [PATCH 1/2] added a health check endpoint --- index.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 593e2e01..af80a997 100644 --- a/index.js +++ b/index.js @@ -63,11 +63,6 @@ app.use(bodyParser.urlencoded({ extended: true })) app.use('/', formWizard) -// file not found handler -app.use((req, res, next) => { - res.status(404).render('file-not-found') -}) - // error handler app.use((err, req, res, next) => { logger.error('Request error', { req, err }) @@ -88,7 +83,18 @@ app.use((err, req, res, next) => { res.status(err.status).render(err.template, { err }) }) +app.get('/health', (req, res) => { + logger.info('healthcheck'); + res.status(200).json({applicationHealth: 'ok'}) +}) + +// file not found handler +app.use((req, res, next) => { + res.status(404).render('file-not-found') +}) + // listen for incomming requests app.listen(config.port, () => { logger.info('App listening on http://localhost::port', { port: config.port }) }) + From 736e86ceb1249ac14148407853f0b86e30a97c89 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Mon, 4 Dec 2023 11:14:49 +0000 Subject: [PATCH 2/2] linting fixes --- index.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index af80a997..133b7a97 100644 --- a/index.js +++ b/index.js @@ -84,8 +84,8 @@ app.use((err, req, res, next) => { }) app.get('/health', (req, res) => { - logger.info('healthcheck'); - res.status(200).json({applicationHealth: 'ok'}) + logger.info('healthcheck') + res.status(200).json({ applicationHealth: 'ok' }) }) // file not found handler @@ -97,4 +97,3 @@ app.use((req, res, next) => { app.listen(config.port, () => { logger.info('App listening on http://localhost::port', { port: config.port }) }) -