improve healthcheck slightly

This commit is contained in:
2025-09-11 20:17:10 +02:00
parent 8ba34f78a9
commit 14ddaa3932

View File

@@ -69,19 +69,33 @@ export function generateRequestBodies() {
* @swagger
* /api/healthcheck:
* get:
* summary: Check if the API is running
* summary: Check if the API is running and if the database is reachable
* responses:
* 200:
* description: API is healthy
* description: API and DB are healthy
* content:
* application/json:
* example:
* status: "ok"
* db: "ok"
* 500:
* description: Database unreachable
* content:
* application/json:
* example:
* status: "error"
* db: "down"
*/
router.get("/healthcheck", (req, res) => {
res.json({ status: "ok" })
router.get("/healthcheck", async (req, res) => {
try {
await pool.query("SELECT 1"); // basic DB check
res.json({ status: "ok", db: "ok" });
} catch {
res.status(500).json({ status: "error", db: "down" });
}
});
/**
* @swagger
* /api/users: