Skip to content

Commit

Permalink
Merge pull request anis-marrouchi#3 from EmeraldLabs/enhancement/chat…
Browse files Browse the repository at this point in the history
…-feature

Enhancement/Chat Feature
  • Loading branch information
amiryamin450 authored Oct 3, 2023
2 parents 829f040 + 45429a1 commit aeead44
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 aeead44

Please sign in to comment.