Skip to content

Commit

Permalink
added a health check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
GeorgeGoodall committed Dec 4, 2023
1 parent f835041 commit 6bf4e91
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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 })
})

0 comments on commit 6bf4e91

Please sign in to comment.