Files
craftvia/src/app/api/v1/sites/[id]/history/route.ts
T
msolarczekandClaude Opus 5 1f8e6413fe L1 Stammdaten: Services, Dublettenprüfung, Server Actions und API v1
Kunden (Nummernkreis, Ansprechpartner, vorläufig bestätigen, Zusammenführen mit
Bestätigung), Objekte inkl. Historie, Teams mit Mitgliedschaften, Dublettenlogik
(lib + Service), API-Kontext/Antwortformat unter src/server/api und die Endpunkte
/api/v1/customers, /api/v1/sites, /api/v1/sites/[id]/history.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-14 12:26:07 +02:00

22 lines
996 B
TypeScript

import { requireApiContext } from "@/server/api/context";
import { json, parsePagination, withApi } from "@/server/api/respond";
import { getSiteHistory } from "@/server/services/sites/history";
/**
* GET /api/v1/sites/:id/history?onlyApproved=true&page&pageSize
* Field roles always receive released deployments only (see getSiteHistory).
*/
export const GET = withApi(async (req: Request, { params }: { params: Promise<{ id: string }> }) => {
const ctx = await requireApiContext("sites", "site:read");
const { id } = await params;
const url = new URL(req.url);
const { page, pageSize } = parsePagination(url, { pageSize: 50 });
const flag = url.searchParams.get("onlyApproved");
const result = await getSiteHistory(ctx, id, { onlyApproved: flag === "true" || flag === "1", page, pageSize });
return json({
data: result.items,
pagination: { page: result.page, pageSize: result.pageSize, total: result.total },
meta: { onlyApproved: result.onlyApproved },
});
});