2026-08-31 19:51:17 +03:00
|
|
|
import { createChat, listChats, titleFromPrompt } from "@/src/server";
|
2026-08-22 02:18:27 +03:00
|
|
|
|
|
|
|
|
export async function GET() {
|
|
|
|
|
return Response.json({ chats: listChats() });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function POST(req: Request) {
|
|
|
|
|
const body = (await req.json().catch(() => ({}))) as { title?: unknown };
|
|
|
|
|
const title = typeof body.title === "string" ? body.title : "";
|
|
|
|
|
const chat = createChat(titleFromPrompt(title || "Untitled session"));
|
|
|
|
|
return Response.json({ id: chat.id, title: chat.title });
|
|
|
|
|
}
|