diff --git a/app/api/room/create/route.tsx b/app/api/room/create/route.tsx deleted file mode 100644 index 59adeaf92..000000000 --- a/app/api/room/create/route.tsx +++ /dev/null @@ -1,38 +0,0 @@ -import { createRoomWithReport } from "@/lib/supabase/createRoomWithReport"; -import { NextRequest } from "next/server"; - -export async function GET(req: NextRequest) { - const topic = req.nextUrl.searchParams.get("topic"); - const account_id = req.nextUrl.searchParams.get("account_id"); - const report_id = req.nextUrl.searchParams.get("report_id"); - const artist_id = req.nextUrl.searchParams.get("artist_id"); - const chat_id = req.nextUrl.searchParams.get("chat_id"); - - if (!topic || !account_id) { - return Response.json( - { message: "Missing required parameters" }, - { status: 400 } - ); - } - - try { - const result = await createRoomWithReport({ - account_id, - topic, - report_id: report_id || undefined, - artist_id: artist_id || undefined, - chat_id: chat_id || undefined, - }); - - return Response.json(result, { status: 200 }); - } catch (error) { - console.error("Error in /api/room/create:", error); - const message = - error instanceof Error ? error.message : "Failed to create room"; - return Response.json({ message }, { status: 400 }); - } -} - -export const dynamic = "force-dynamic"; -export const fetchCache = "force-no-store"; -export const revalidate = 0; diff --git a/app/api/sandbox/upload/route.ts b/app/api/sandbox/upload/route.ts index 48f2395c5..2fb52414b 100644 --- a/app/api/sandbox/upload/route.ts +++ b/app/api/sandbox/upload/route.ts @@ -25,6 +25,7 @@ export async function POST(request: Request): Promise { return { maximumSizeInBytes: 100 * 1024 * 1024, // 100MB + addRandomSuffix: true, }; }, onUploadCompleted: async () => {}, diff --git a/lib/sandboxes/uploadSandboxFiles.ts b/lib/sandboxes/uploadSandboxFiles.ts index d0e3f56ca..c7db2d161 100644 --- a/lib/sandboxes/uploadSandboxFiles.ts +++ b/lib/sandboxes/uploadSandboxFiles.ts @@ -36,7 +36,7 @@ export async function uploadSandboxFiles({ path?: string; message?: string; }): Promise<{ uploaded: UploadedFile[]; errors?: string[] }> { - const blobFiles = await Promise.all( + const results = await Promise.allSettled( files.map(async (file) => { const blob = await upload(file.name, file, { access: "public", @@ -47,6 +47,23 @@ export async function uploadSandboxFiles({ }), ); + const blobFiles: { url: string; name: string }[] = []; + const blobErrors: string[] = []; + + results.forEach((r, i) => { + if (r.status === "fulfilled") { + blobFiles.push(r.value); + } else { + blobErrors.push(`${files[i].name}: ${r.reason?.message || "Upload failed"}`); + } + }); + + if (blobFiles.length === 0) { + throw new Error( + blobErrors[0] || "Failed to upload files to temporary storage", + ); + } + const response = await fetch(`${NEW_API_BASE_URL}/api/sandboxes/files`, { method: "POST", headers: { @@ -66,8 +83,10 @@ export async function uploadSandboxFiles({ throw new Error(data.error || "Failed to upload files"); } + const allErrors = [...blobErrors, ...(data.errors || [])]; + return { uploaded: data.uploaded || [], - errors: data.errors, + ...(allErrors.length > 0 && { errors: allErrors }), }; }