From a17125bdeefc4125ab3e2b3ae4fdda4b3eca60f2 Mon Sep 17 00:00:00 2001 From: Sven laptop Date: Mon, 21 Sep 2026 19:59:53 +0200 Subject: [PATCH] fixed monitor api polling --- auth_api/index.js | 4 ++++ employee_api/index.js | 13 ++++--------- error_log_api/index.js | 8 +++++++- monitoring_ui/src/App.jsx | 2 +- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/auth_api/index.js b/auth_api/index.js index 8eb0cbe..2306be5 100644 --- a/auth_api/index.js +++ b/auth_api/index.js @@ -129,4 +129,8 @@ app.get("/me", async (req, res) => { const PORT = process.env.PORT || 5000; app.listen(PORT, () => console.log(`Auth API listening on ${PORT}`)); +app.get("/health", (_req, res) => { + res.json({ status: "ok", service: "auth_api" }); +}); + module.exports = app; diff --git a/employee_api/index.js b/employee_api/index.js index 5c87262..e6ea7f1 100644 --- a/employee_api/index.js +++ b/employee_api/index.js @@ -91,18 +91,13 @@ app.post("/createemployee", async (req, res) => { } }); -app.get("/health", async (_req, res, _next) => { +app.get("/health", async (_req, res) => { try { - return res.status(200).json({ endpoint: "reachable" }); + await db.query("SELECT 1"); + return res.status(200).json({ endpoint: "reachable", database: "ok" }); } catch (err) { - void reportError({ - partofservice: `${req.method} ${req.originalUrl}`, - error: err?.stack || err?.message || String(err), - }); console.error(err); - res - .status(500) - .json({ endpoint: "unreachable", error: friendlyErrorMessage(500) }); + res.status(503).json({ endpoint: "unreachable", database: "down" }); } }); diff --git a/error_log_api/index.js b/error_log_api/index.js index cbb69db..7dda828 100644 --- a/error_log_api/index.js +++ b/error_log_api/index.js @@ -70,7 +70,13 @@ function verifyAdmin(req, res, next) { } app.get("/health", async (_req, res) => { - res.json({ status: "ok", service: "error_log_api" }); + try { + await db.query("SELECT 1"); + res.json({ status: "ok", service: "error_log_api", database: "ok" }); + } catch (err) { + console.error("GET /health error:", err); + res.status(503).json({ status: "unavailable", service: "error_log_api" }); + } }); app.post("/error_log", async (req, res) => { diff --git a/monitoring_ui/src/App.jsx b/monitoring_ui/src/App.jsx index c1244d7..eafb72a 100644 --- a/monitoring_ui/src/App.jsx +++ b/monitoring_ui/src/App.jsx @@ -70,7 +70,7 @@ const serviceMeta = { }; const healthPaths = { - auth: "/me", + auth: "/health", employee: "/health", transit: "/health", errors: "/health",