Implement notification creation and deletion endpoints

This commit is contained in:
headlessdev
2025-04-17 14:13:21 +02:00
parent 2fd8e50f7f
commit 346b79ca22
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import { NextResponse, NextRequest } from "next/server";
import { prisma } from "@/lib/prisma";
export async function POST(request: NextRequest) {
try {
const body = await request.json();
const id = Number(body.id);
if (!id) {
return NextResponse.json({ error: "Missing ID" }, { status: 400 });
}
await prisma.notification.delete({
where: { id: id }
});
return NextResponse.json({ success: true });
} catch (error: any) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}