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

Function POST

web/app/api/share/route.ts:14–50  ·  view source on GitHub ↗
(req: NextRequest)

Source from the content-addressed store, hash-verified

12}
13
14export async function POST(req: NextRequest) {
15 let body: CreateShareRequest;
16 try {
17 body = await req.json();
18 } catch {
19 return NextResponse.json({ error: "Invalid JSON body" }, { status: 400 });
20 }
21
22 const { conversation, visibility, password, expiry } = body;
23 if (!conversation || !visibility || !expiry) {
24 return NextResponse.json({ error: "Missing required fields" }, { status: 400 });
25 }
26
27 if (visibility === "password" && !password) {
28 return NextResponse.json(
29 { error: "Password required for password-protected shares" },
30 { status: 400 }
31 );
32 }
33
34 const shareId = nanoid(12);
35 const share = createShare(shareId, { conversation, visibility, password, expiry });
36
37 const origin = req.headers.get("origin") ?? "";
38 const url = `${origin}/share/${shareId}`;
39
40 return NextResponse.json({
41 id: share.id,
42 conversationId: share.conversationId,
43 visibility: share.visibility,
44 hasPassword: !!share.passwordHash,
45 expiry: share.expiry,
46 expiresAt: share.expiresAt,
47 createdAt: share.createdAt,
48 url,
49 });
50}

Callers

nothing calls this directly

Calls 2

createShareFunction · 0.90
getMethod · 0.65

Tested by

no test coverage detected