MCPcopy Create free account
hub / github.com/codeaashu/claude-code / POST

Function POST

web/app/api/files/write/route.ts:5–31  ·  view source on GitHub ↗
(request: NextRequest)

Source from the content-addressed store, hash-verified

3import path from "path";
4
5export async function POST(request: NextRequest) {
6 let body: { path?: string; content?: string };
7 try {
8 body = await request.json();
9 } catch {
10 return NextResponse.json({ error: "invalid JSON body" }, { status: 400 });
11 }
12
13 const { path: filePath, content } = body;
14 if (!filePath || content === undefined) {
15 return NextResponse.json(
16 { error: "path and content are required" },
17 { status: 400 }
18 );
19 }
20
21 const resolvedPath = path.resolve(filePath);
22
23 try {
24 await fs.writeFile(resolvedPath, content, "utf-8");
25 const stats = await fs.stat(resolvedPath);
26 return NextResponse.json({ success: true, size: stats.size });
27 } catch (err) {
28 const message = err instanceof Error ? err.message : "Unknown error";
29 return NextResponse.json({ error: message }, { status: 500 });
30 }
31}

Callers

nothing calls this directly

Calls 1

resolveMethod · 0.45

Tested by

no test coverage detected