import { db } from "../db/client.js";
import { loadInstallConfig } from "../config.js";
export function registerHealthRoutes(app) {
    app.get("/health", async () => ({
        status: "ok",
        service: "private-server",
        /** false tant que l'assistant de premier lancement n'a pas tourné. */
        setupDone: loadInstallConfig().setupDoneAt !== null,
        time: new Date().toISOString(),
    }));
    app.get("/health/ready", async (_req, reply) => {
        try {
            db.$client.prepare("SELECT 1").get();
            reply.send({ status: "ok", db: "up" });
        }
        catch (err) {
            reply.status(503).send({ status: "degraded", db: "down" });
            void err;
        }
    });
}
//# sourceMappingURL=health.js.map