Edit network

This commit is contained in:
headlesdev
2025-05-18 16:59:16 +02:00
parent d4ad6e1656
commit 56571ba65a
4 changed files with 156 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
import { NextRequest, NextResponse } from "next/server";
import prisma from "@/app/prisma";
interface Body {
id: string;
name: string;
ipv4Subnet?: string;
ipv6Subnet?: string;
gateway?: string;
}
export async function POST(request: NextRequest) {
const body: Body = await request.json();
try {
const network = await prisma.network.update({
where: {
id: Number(body.id),
},
data: {
name: body.name,
ipv4Subnet: body.ipv4Subnet,
ipv6Subnet: body.ipv6Subnet,
gateway: body.gateway,
},
});
return NextResponse.json({ network }, { status: 201 });
} catch (error) {
console.error("Error editing network:", error);
return NextResponse.json({ error: "Failed to edit network" }, { status: 500 });
}
}