diff --git a/app/api/chat-listing/[childId]/route.ts b/app/api/chat-listing/[childId]/route.ts new file mode 100644 index 0000000..f1be325 --- /dev/null +++ b/app/api/chat-listing/[childId]/route.ts @@ -0,0 +1,19 @@ +import { NextRequest, NextResponse } from "next/server" + +import { createPrisma } from "@/lib/prisma" + +// @ts-ignore +export async function GET(request: NextRequest, { params: { childId } }) { + const credentials = { + supabaseDatabaseUrl: process.env.DATABASE_URL, + } + const prisma = createPrisma({ url: credentials.supabaseDatabaseUrl }) + + const data = await prisma.chatHistory.findMany({ + where: { + childId, + }, + }) + + return NextResponse.json({ data }) +} diff --git a/app/api/chat/[id]/route.ts b/app/api/chat/[id]/route.ts new file mode 100644 index 0000000..877a4ca --- /dev/null +++ b/app/api/chat/[id]/route.ts @@ -0,0 +1,19 @@ +import { NextRequest, NextResponse } from "next/server" + +import { createPrisma } from "@/lib/prisma" + +// @ts-ignore +export async function GET(request: NextRequest, { params: { id } }) { + const credentials = { + supabaseDatabaseUrl: process.env.DATABASE_URL, + } + const prisma = createPrisma({ url: credentials.supabaseDatabaseUrl }) + + const data = await prisma.chatHistory.findFirst({ + where: { + id, + }, + }) + + return NextResponse.json({ data }) +}