import type { FastifyPluginAsyncZod } from 'fastify-type-provider-zod'; import { z } from 'zod'; import { dataRelease } from '../lib/envelope.js'; export const healthRoutes: FastifyPluginAsyncZod = async (app) => { // Root of the API host: a minimal, honest landing (used while the web app is not yet in front). app.get('/', { schema: { hide: true }, config: { rateLimit: false } }, async (_req, reply) => { reply.type('text/html; charset=utf-8'); return `
This host serves the public API (v1). The web interface is being deployed.
CancerIndex is a research and information platform. It is not a physician, does not diagnose, and does not recommend treatment.
`; }); app.get( '/healthz', { schema: { tags: ['system'], summary: 'Liveness/readiness probe', response: { 200: z.object({ ok: z.boolean(), dataRelease: z.string(), db: z.boolean(), service: z.string(), uptimeSeconds: z.number() }) }, }, config: { rateLimit: false }, }, async (_req, reply) => { const db = await app.dbHealthy(); reply.code(db ? 200 : 200); return { ok: db, dataRelease: dataRelease(), db, service: 'cancerindex-api', uptimeSeconds: Math.round(process.uptime()) }; }, ); };