mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-18 07:56:57 +00:00
Prevent deletions of servers with associated applications
This commit is contained in:
parent
e844712c29
commit
d779355c4c
@ -9,6 +9,14 @@ export async function POST(request: NextRequest) {
|
|||||||
if (!id) {
|
if (!id) {
|
||||||
return NextResponse.json({ error: "Missing ID" }, { status: 400 });
|
return NextResponse.json({ error: "Missing ID" }, { status: 400 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if there are any applications associated with the server
|
||||||
|
const applications = await prisma.application.findMany({
|
||||||
|
where: { serverId: id }
|
||||||
|
});
|
||||||
|
if (applications.length > 0) {
|
||||||
|
return NextResponse.json({ error: "Cannot delete server with associated applications" }, { status: 400 });
|
||||||
|
}
|
||||||
|
|
||||||
await prisma.server.delete({
|
await prisma.server.delete({
|
||||||
where: { id: id }
|
where: { id: id }
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user