import type { FastifyInstance } from 'fastify'; import { prisma } from '../db.js'; export async function healthRoutes(app: FastifyInstance) { app.get('/health', async () => ({ ok: true, ts: new Date().toISOString() })); app.get('/health/db', async (_req, reply) => { try { await prisma.$queryRaw`SELECT 1`; return { ok: true }; } catch (e) { app.log.error({ err: e }, 'db health check failed'); reply.code(503).send({ ok: false, error: 'db_unavailable' }); } }); }