38 lines
821 B
TypeScript
38 lines
821 B
TypeScript
import { prisma } from "@/app/lib/prisma"
|
|
import { NextResponse } from "next/server"
|
|
|
|
export async function GET(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const { id } = await params
|
|
|
|
const conversation = await prisma.conversation.findUnique({
|
|
where: { id: parseInt(id) },
|
|
include: {
|
|
messages: {
|
|
orderBy: { timestamp: "asc" },
|
|
},
|
|
},
|
|
})
|
|
|
|
if (!conversation) {
|
|
return NextResponse.json({ error: "Conversation not found" }, { status: 404 })
|
|
}
|
|
|
|
return NextResponse.json(conversation)
|
|
}
|
|
|
|
export async function DELETE(
|
|
request: Request,
|
|
{ params }: { params: Promise<{ id: string }> }
|
|
) {
|
|
const { id } = await params
|
|
|
|
await prisma.conversation.delete({
|
|
where: { id: parseInt(id) },
|
|
})
|
|
|
|
return NextResponse.json({ success: true })
|
|
}
|