improve healthcheck slightly
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user