spb/chat-spboucher-ai
Public
1import { z } from "zod";2import { guarded, json, body } from "@/lib/api";3import { listConversations, createConversation } from "@/lib/chat/store";45export const GET = guarded(async (req) => {6 const p = req.nextUrl.searchParams;7 const projectId = p.has("project") ? (p.get("project") || null) : undefined;8 const rows = await listConversations({ projectId, archived: p.get("archived") === "1", q: p.get("q") ?? undefined, limit: Number(p.get("limit") ?? 300) });9 return json({ conversations: rows });10});1112export const POST = guarded(async (req) => {13 const b = await body(req, z.object({ projectId: z.string().nullable().optional(), modelId: z.string().nullable().optional(), title: z.string().max(200).optional(), mode: z.enum(["chat", "compare", "research"]).optional(), settings: z.record(z.string(), z.unknown()).optional() }));14 const conv = await createConversation(b);15 return json({ conversation: conv }, { status: 201 });16});17