mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Edit network
This commit is contained in:
33
app/api/sites/networks/edit/route.ts
Normal file
33
app/api/sites/networks/edit/route.ts
Normal 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 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user