import type { FastifyPluginAsyncZod } from "fastify-type-provider-zod" import { z } from "zod" const healthResponse = z.object({ status: z.literal("ok"), uptime: z.number(), timestamp: z.iso.datetime(), }) /** GET /health — liveness per Docker/Caddy. Escluso dal rate limit. */ const healthRoutes: FastifyPluginAsyncZod = async (app) => { app.get( "/health", { config: { rateLimit: false }, // Healthcheck Docker ogni 15 s: niente righe "incoming request"/"request completed" nei log (errori sì) logLevel: "warn", schema: { response: { 200: healthResponse } }, }, async () => ({ status: "ok" as const, uptime: Math.round(process.uptime()), timestamp: new Date().toISOString(), }), ) } export default healthRoutes