32 lines
836 B
TypeScript
32 lines
836 B
TypeScript
import { z } from "zod";
|
|
|
|
import { getAdminOk, handleSetCaptureOverride } from "./handlers";
|
|
|
|
export const runtime = "nodejs";
|
|
|
|
const paramsSchema = z.object({
|
|
id: z.string().uuid(),
|
|
});
|
|
|
|
export async function POST(
|
|
request: Request,
|
|
context: { params: Promise<{ id: string }> },
|
|
): Promise<Response> {
|
|
const rawParams = await context.params;
|
|
const paramsParsed = paramsSchema.safeParse(rawParams);
|
|
if (!paramsParsed.success) {
|
|
return Response.json(
|
|
{ error: "invalid_params", issues: paramsParsed.error.issues },
|
|
{ status: 400 },
|
|
);
|
|
}
|
|
|
|
const bodyJson = await request.json().catch(() => ({}));
|
|
const res = await handleSetCaptureOverride({
|
|
adminOk: getAdminOk(request.headers),
|
|
params: paramsParsed.data,
|
|
body: bodyJson,
|
|
});
|
|
return Response.json(res.body, { status: res.status });
|
|
}
|