Update application code and dependencies
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { prisma } from "@/app/lib/prisma"
|
||||
import { NextResponse } from "next/server"
|
||||
|
||||
export async function POST(
|
||||
request: Request,
|
||||
{ params }: { params: Promise<{ id: string }> }
|
||||
) {
|
||||
const { id } = await params
|
||||
const body = await request.json()
|
||||
const { role, content } = body
|
||||
|
||||
if (!role || !content) {
|
||||
return NextResponse.json({ error: "role and content are required" }, { status: 400 })
|
||||
}
|
||||
|
||||
const message = await prisma.message.create({
|
||||
data: {
|
||||
conversationId: parseInt(id),
|
||||
role,
|
||||
content,
|
||||
},
|
||||
})
|
||||
|
||||
await prisma.conversation.update({
|
||||
where: { id: parseInt(id) },
|
||||
data: { updatedAt: new Date() },
|
||||
})
|
||||
|
||||
return NextResponse.json(message)
|
||||
}
|
||||
Reference in New Issue
Block a user