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
20 lines
930 B
TypeScript
20 lines
930 B
TypeScript
import { NextResponse, type NextRequest } from "next/server";
|
|
import { callMobileApiBinary } from "@/app/lib/server/mobileApi";
|
|
import { getToken } from "@/app/lib/server/session";
|
|
import { errorResponse, unauthorized } from "@/app/lib/server/apiRoute";
|
|
|
|
// xlsx export of the lead listing; mobile-api owns validation and the BO_LEADS + BO_LEADS_EXPORT guards.
|
|
export async function GET(req: NextRequest) {
|
|
const token = await getToken();
|
|
if (!token) return unauthorized();
|
|
const result = await callMobileApiBinary(`/api/admin/leads/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 } : {}),
|
|
},
|
|
});
|
|
}
|