chatbot-template/app/(chat)/api/history/route.ts

14 lines
354 B
TypeScript
Raw Normal View History

2024-10-11 18:00:22 +05:30
import { auth } from "@/app/(auth)/auth";
import { getChatsByUserId } from "@/db/queries";
export async function GET() {
const session = await auth();
if (!session || !session.user) {
return Response.json("Unauthorized!", { status: 401 });
}
const chats = await getChatsByUserId({ id: session.user.id! });
return Response.json(chats);
}