import Fastify, { type FastifyInstance } from "fastify"; import { REPORT_LINKS } from "./links.js"; import { renderIndex } from "./page.js"; /** * Список отчётов. Без собственной авторизации: порт слушает только 127.0.0.1, наружу сервис выставляет nginx * (reports.khbuild.freeddns.org) за входом Keycloak (oauth2-proxy). Никаких данных, кроме статических ссылок, он не отдаёт. */ export function buildApi(): FastifyInstance { const app = Fastify(); const page = renderIndex(); app.get("/healthz", async () => ({ ok: true, links: REPORT_LINKS.length, time: new Date().toISOString() })); app.get("/", async (_req, reply) => reply.header("cache-control", "no-store").type("text/html; charset=utf-8").send(page)); app.get("/api/links", async () => REPORT_LINKS); return app; }