From 9f87535a0357dd629565a91d0298b8c2a81c67b7 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 12 May 2019 13:15:23 -0400 Subject: [PATCH] feat: healthz endpoint --- server/controllers/common.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/server/controllers/common.js b/server/controllers/common.js index 1dd2cef1..6de24eda 100644 --- a/server/controllers/common.js +++ b/server/controllers/common.js @@ -17,6 +17,17 @@ router.get('/robots.txt', (req, res, next) => { } }) +/** + * Health Endpoint + */ +router.get('/healthz', (req, res, next) => { + if (WIKI.models.knex.client.pool.numFree() < 1 && WIKI.models.knex.client.pool.numUsed() < 1) { + res.status(503).json({ ok: false }).end() + } else { + res.status(200).json({ ok: true }).end() + } +}) + /** * Create/Edit document */