import type { FastifyInstance } from "fastify";
import { route } from "../../core/http/route.js";
import * as s from "./audit.service.js";

const P = "/api/projects/:projectId", A = `${P}/audit`;
export async function auditRoutes(app: FastifyInstance): Promise<void> {
  route(app, "GET", "/projects/:p/audit/events", { perm: "audit.view", v1: [`GET ${A}/events`, `GET ${P}/submission-events`] }, async (c) => s.events(c));
  route(app, "POST", "/projects/:p/audit/verify", { perm: "audit.verify", v1: [`GET ${A}/integrity`, `GET ${P}/ops/audit-integrity`] }, async (c) => s.verify(c));
  route(app, "POST", "/projects/:p/audit/export-bundle", { perm: "audit.export", v1: [`GET ${A}/export-bundle`] }, async (c) => s.exportBundle(c));
  route(app, "POST", "/projects/:p/audit/verify-bundle", { perm: "audit.verify", v1: [`POST ${A}/verify-bundle`] }, async (c) => s.verifyBundle(c));
}
