-
Notifications
You must be signed in to change notification settings - Fork 4
/
setupHealthChecks.ts
40 lines (35 loc) · 1.25 KB
/
setupHealthChecks.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import express from 'express'
import config from './config'
import healthFactory from './services/healthCheck'
import { joinUrlPath } from './utils'
const router = express.Router()
const health = healthFactory(
joinUrlPath(config.apis.oauth2.url, '/health/ping'),
joinUrlPath(config.apis.hmppsManageUsers.url, '/health/ping'),
joinUrlPath(config.apis.prisonApi.url, '/health/ping'),
joinUrlPath(config.apis.whereabouts.url, '/health/ping'),
joinUrlPath(config.apis.deliusIntegration.url, '/health'),
joinUrlPath(config.apis.keyworker.url, '/health/ping'),
joinUrlPath(config.apis.caseNotes.url, '/health/ping'),
joinUrlPath(config.apis.allocationManager.url, '/health'),
joinUrlPath(config.apis.tokenverification.url, '/health/ping'),
joinUrlPath(config.apis.offenderSearch.url, '/health/ping'),
joinUrlPath(config.apis.complexity.url, '/ping'),
joinUrlPath(config.apis.incentivesApi.url, '/health/ping')
)
export default () => {
router.get('/health', (req, res, next) => {
health((err, result) => {
if (err) {
return next(err)
}
if (!(result.status === 'UP')) {
res.status(503)
}
res.json(result)
return result
})
})
router.get('/ping', (req, res) => res.send('pong'))
return router
}