The export routes wait up to 120 s as the design says, instead of the 30 s default. Event names and updatedAt can be null, and a history card for a removed event shows no empty name line. Notes on export paging and on url-less folder modules in the ACL menu. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
24 lines
1.2 KiB
TypeScript
24 lines
1.2 KiB
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { callMobileApiBinary } from "@/app/lib/server/mobileApi";
|
|
import { getToken } from "@/app/lib/server/session";
|
|
import { badRequest, errorResponse, unauthorized } from "@/app/lib/server/apiRoute";
|
|
|
|
// xlsx export of one event's leads; mobile-api owns validation and the BO_EVENT_LEADS + BO_LEADS_EXPORT guards.
|
|
type Ctx = { params: Promise<{ eventUuid: string }> };
|
|
|
|
export async function GET(req: NextRequest, { params }: Ctx) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const { eventUuid } = await params;
|
|
if (eventUuid === "." || eventUuid === "..") return badRequest("Invalid path.");
|
|
const result = await callMobileApiBinary(`/api/admin/event-leads/${encodeURIComponent(eventUuid)}/export${new URL(req.url).search}`, { token, timeoutMs: 120_000 });
|
|
if (!result.ok) return errorResponse(result);
|
|
const { body, contentType, contentDisposition } = result.data;
|
|
return new NextResponse(body, {
|
|
headers: {
|
|
...(contentType ? { "Content-Type": contentType } : {}),
|
|
...(contentDisposition ? { "Content-Disposition": contentDisposition } : {}),
|
|
},
|
|
});
|
|
}
|