-
DESKTOP-9FO96TP\hehexd authoredDESKTOP-9FO96TP\hehexd authored
route.ts 969 B
import { NextRequest, NextResponse } from "next/server";
import { prisma } from "@/prisma/db"
import { Prisma} from "@prisma/client"
import { putLike } from "./likeService";
type like = Prisma.LikeUncheckedCreateInput
export async function PUT(req: NextRequest) {
const data:like = await req.json()
console.log("router data: " + data, "status:")
console.log(data)
try {
await putLike(data)
return NextResponse.json({ status: 200, message: 'Like handled' })
} catch (error) {
console.log("fail" + error);
return NextResponse.json(error, { status: 500 });
}
}
export async function DELETE(req: NextRequest, res:NextResponse) {
const data = await req.json()
console.log("router data: " + data, "status:")
console.log(data)
try {
const messages = await prisma.message.findMany({
})
return NextResponse.json({ status: 200, messages: messages })
} catch (error) {
console.log("fail" + error);
// res.status(400)
}
console.log("get")
}