mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
25 lines
865 B
TypeScript
25 lines
865 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import prisma from "@/app/prisma";
|
|
import { z } from "zod/v4";
|
|
|
|
const schema = z.object({
|
|
notificationId: z.string(),
|
|
});
|
|
|
|
export async function DELETE(request: NextRequest) {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const notificationId = schema.parse({ notificationId: searchParams.get("notificationId") });
|
|
|
|
try {
|
|
const notification = await prisma.notificationProvider.delete({
|
|
where: { id: parseInt(notificationId.notificationId) },
|
|
});
|
|
|
|
return NextResponse.json(notification);
|
|
} catch (error: any) {
|
|
if(error instanceof z.ZodError) {
|
|
return NextResponse.json({ error: error.issues[0].message }, { status: 400 });
|
|
}
|
|
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
|
|
}
|
|
} |