Skip to content

Commit

Permalink
chat listing and chat detail endpoints are added
Browse files Browse the repository at this point in the history
  • Loading branch information
naqi committed Oct 3, 2023
1 parent 829f040 commit 45429a1
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions app/api/chat-listing/[childId]/route.ts
Original file line number Diff line number Diff line change
@@ -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 })
}
19 changes: 19 additions & 0 deletions app/api/chat/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -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 })
}

0 comments on commit 45429a1

Please sign in to comment.