Implementa o MVP do Adaptador de Planilhas no Elo Pro.
O módulo usa a identidade Supabase, isola cada workspace e registra storage, TTL, runner e biblioteca XLSX como decisões ainda abertas. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
6e23f1533b
144 files changed
+19060
No files matched your search
@@ -0,0 +1,31 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import { errorResponse, requireReady } from "../../../_lib";
|
||||
import { downloadOutput } from "@/server/spreadsheet-adapter/process-job";
|
||||
import type { OutputFormat } from "@/domain/spreadsheet-adapter/types";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
export async function GET(request: Request, context: { params: Promise<{ id: string }> }) {
|
||||
try {
|
||||
const { ctx, deps } = await requireReady();
|
||||
const { id } = await context.params;
|
||||
const url = new URL(request.url);
|
||||
const format = url.searchParams.get("format") as OutputFormat | null;
|
||||
const sourceId = url.searchParams.get("sourceId");
|
||||
if (!sourceId || (format !== "xlsx" && format !== "csv" && format !== "pdf")) {
|
||||
return NextResponse.json({ error: { code: "INVALID_FORMAT", message: "Escolha XLSX, CSV ou PDF." } }, { status: 400 });
|
||||
}
|
||||
const file = await downloadOutput(deps, ctx, id, sourceId, format);
|
||||
return new NextResponse(new Uint8Array(file.body), {
|
||||
headers: {
|
||||
"Content-Type": file.contentType,
|
||||
"Content-Disposition": `attachment; filename="${file.filename}"`,
|
||||
"Cache-Control": "no-store",
|
||||
"X-Content-Type-Options": "nosniff",
|
||||
},
|
||||
});
|
||||
} catch (error) {
|
||||
return errorResponse(error);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user