"use strict";
const { Router } = require("express");
const { testConnection } = require("../db");
const router = Router();

router.get("/healthz", async (_req, res) => {
  try {
    await testConnection();
    res.json({ status: "ok", db: "connected", ts: new Date().toISOString() });
  } catch (e) {
    res.status(503).json({ status: "error", db: "disconnected", error: e.message });
  }
});

module.exports = router;
