Files
co-lite/solvway-admin-portal/app/api/event-leads/[eventUuid]/export/route.ts
T
ngqileandClaude Opus 5.5 29a3f13503 fix: export route timeout and nullable lead fields from the branch review
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
2026-11-27 17:35:35 +08:00

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 } : {}),
},
});
}