This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { errorResponse } from "../../../../../lib/http";
|
||||
import { writeProjectFiles } from "../../../../../lib/storage";
|
||||
|
||||
export const runtime = "nodejs";
|
||||
|
||||
export async function POST(request: NextRequest, context: { params: Promise<{ id: string }> }) {
|
||||
try {
|
||||
const { id } = await context.params;
|
||||
const body = await request.json();
|
||||
if (!Array.isArray(body.changes) || body.changes.some((item: unknown) => !item || typeof (item as { path?: unknown }).path !== "string" || typeof (item as { content?: unknown }).content !== "string")) throw new Error("changes must contain path and content strings");
|
||||
return NextResponse.json({ project: await writeProjectFiles(id, body.changes, body.revision) });
|
||||
} catch (error) { return errorResponse(error); }
|
||||
}
|
||||
Reference in New Issue
Block a user