fix: Mount _health route before catch-alls

closes #2536
This commit is contained in:
Tom Moor
2021-09-09 21:08:34 -07:00
parent 8ac853bb8b
commit 995c6f90b7

View File

@ -48,6 +48,10 @@ async function start(id, disconnect) {
app.use(compress());
app.use(helmet());
// install health check endpoint for all services
router.get("/_health", (ctx) => (ctx.body = "OK"));
app.use(router.routes());
// loop through requestsed services at startup
for (const name of serviceNames) {
if (!Object.keys(services).includes(name)) {
@ -59,10 +63,6 @@ async function start(id, disconnect) {
await init(app, server);
}
// install health check endpoint for all services
router.get("/_health", (ctx) => (ctx.body = "OK"));
app.use(router.routes());
server.on("error", (err) => {
throw err;
});