Engineering manualAPI route source
/api/brand-studio/brand-kit
Exact current route handler: hosted-app/app/api/brand-studio/brand-kit/route.js
Methods: GET. Input signals: query parameters. Literal response-status signals: 200.
Source: hosted-app/app/api/brand-studio/brand-kit/route.js. Imports: ../../../../lib/comprehensive-pull-handler.mjs, ../../../../lib/report-capture-source.mjs, ../../../../lib/report-downloads.mjs, ../../../../lib/supabase-rest.mjs, next/server. Exact source is shown for inspection; its presence does not prove authentication, validation or live behavior.
All API routes · API and execution contract
// The brand kit .zip — the second item in the report's download menu, and the
// one the launch review found pointing at a route that does not exist on this
// origin.
//
// Assembled in memory (lib/report-downloads.mjs) and zipped in memory
// (lib/zip.mjs), because a serverless function has no `zip` binary and this
// app carries no dependencies to add one. What comes out is the panel's kit:
// brand-summary.md, the palette as CSS and JSON, the fonts, the ranked logos
// (with the files it could fetch), the untouched capture, and a manifest that
// accounts for every byte in it.
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
// Fetching a handful of logo files over HTTP is the only slow part, and it is
// bounded by its own per-request timeout.
export const maxDuration = 60;
import { NextResponse } from "next/server";
import { supabaseConfigFromEnv } from "../../../../lib/supabase-rest.mjs";
import { bearerTokenFromHeader } from "../../../../lib/comprehensive-pull-handler.mjs";
import { resolveCaptureForDownload } from "../../../../lib/report-capture-source.mjs";
import { buildBrandKitArchive } from "../../../../lib/report-downloads.mjs";
const fileSlug = (value) => String(value || "brand").replace(/[^\w.-]+/g, "-").replace(/^-+|-+$/g, "") || "brand";
export async function GET(request) {
const runId = new URL(request.url).searchParams.get("run_id") || "";
const token = bearerTokenFromHeader(request.headers.get("authorization"));
const source = await resolveCaptureForDownload({
runId,
token,
config: supabaseConfigFromEnv(process.env)
});
if (!source.ok) return NextResponse.json(source.body, { status: source.http_status });
const { archive } = await buildBrandKitArchive({
captureResult: source.captureResult,
runId: source.runId,
reportId: source.reportId || source.runId,
overrides: source.overrides || []
});
return new NextResponse(archive, {
status: 200,
headers: {
"content-type": "application/zip",
"cache-control": "no-store",
"content-length": String(archive.length),
"content-disposition": `attachment; filename="${fileSlug(source.domain || source.runId)}-brand-kit.zip"`
}
});
}