TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1import { z } from "zod";2import { withUser, parseBody, json } from "@/lib/api";3import { attachFiles } from "@/lib/library/service";45export const dynamic = "force-dynamic";67/**8 * POST /api/library/files/attach { fileIds: string[] } → { attachments: [{ id, kind, name, mimeType, sizeBytes, width, height }] }9 * Each library file is copied into `message_attachments` as a pending attachment (no message/conversation yet),10 * i.e. the same shape POST /api/attachments returns, so the composer can send the ids in `message.attachmentIds`.11 */12export const POST = withUser(async ({ req, user }) => {13 const body = await parseBody(req, z.object({ fileIds: z.array(z.string().max(64)).min(1).max(10) }));14 return json({ attachments: await attachFiles(user.id, body.fileIds) }, { status: 201 });15});16