Skip to content

Commit

Permalink
Remove the healthcheck from request/response logging
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilkybarkid committed Aug 28, 2024
1 parent 3fc0404 commit 37cea29
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,27 @@ const withEnv =
export const app = (config: ConfigEnv) =>
express()
.disable('x-powered-by')
.get(
'/health',
asyncHandler(async (req, res) => {
if (config.redis === undefined) {
res.json({ status: 'ok' })
return
}
try {
if (config.redis.status !== 'ready') {
throw new Error(`Redis not ready (${config.redis.status})`)
}
await config.redis.ping()
} catch (error) {
const foo = toError(error)
L.errorP('healthcheck failed')({ message: foo.message, name: foo.name })(config)()
res.status(503).json({ status: 'error' })
return
}
res.json({ status: 'ok' })
}),
)
.use((req, res, next) => {
const url = new URL(req.url, config.publicUrl)

Expand Down Expand Up @@ -217,27 +238,6 @@ export const app = (config: ConfigEnv) =>
res.type('text/plain')
res.send('User-agent: *\nAllow: /')
})
.get(
'/health',
asyncHandler(async (req, res) => {
if (config.redis === undefined) {
res.json({ status: 'ok' })
return
}
try {
if (config.redis.status !== 'ready') {
throw new Error(`Redis not ready (${config.redis.status})`)
}
await config.redis.ping()
} catch (error) {
const foo = toError(error)
L.errorP('healthcheck failed')({ message: foo.message, name: foo.name })(config)()
res.status(503).json({ status: 'error' })
return
}
res.json({ status: 'ok' })
}),
)
.use(
express.static('dist/assets', {
setHeaders: (res, path) => {
Expand Down

0 comments on commit 37cea29

Please sign in to comment.