mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import prisma from "@/app/prisma";
|
|
import { z } from "zod/v4";
|
|
|
|
const schema = z.object({
|
|
notificationTestId: z.string()
|
|
})
|
|
|
|
export async function GET(request: NextRequest) {
|
|
try {
|
|
const searchParams = request.nextUrl.searchParams;
|
|
const notificationTestId = schema.parse({ notificationTestId: searchParams.get('notificationTestId') });
|
|
|
|
if(!notificationTestId) {
|
|
return NextResponse.json({ error: "Notification test ID is required" }, { status: 400 });
|
|
}
|
|
|
|
const notificationTest = await prisma.notificationTest.findUnique({
|
|
where: { id: parseInt(notificationTestId.notificationTestId) }
|
|
})
|
|
|
|
if(!notificationTest) {
|
|
return NextResponse.json({ error: "Notification test not found" }, { status: 404 });
|
|
}
|
|
|
|
return NextResponse.json({ notificationTest }, { status: 200 });
|
|
} catch (error) {
|
|
if(error instanceof z.ZodError) {
|
|
return NextResponse.json({ error: error.issues[0].message }, { status: 400 });
|
|
}
|
|
return NextResponse.json({ error: "Internal server error" }, { status: 500 });
|
|
}
|
|
} |