mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-20 00:46:47 +00:00
28 lines
725 B
TypeScript
28 lines
725 B
TypeScript
import { NextRequest, NextResponse } from "next/server";
|
|
import prisma from "@/app/prisma";
|
|
import { Network } from "@/app/types";
|
|
|
|
interface Body {
|
|
id: string;
|
|
name: string;
|
|
description: string;
|
|
networks: Network[];
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
const body: Body = await request.json();
|
|
const { id, name, description, networks } = body;
|
|
|
|
try {
|
|
const site = await prisma.site.update({
|
|
where: { id: Number(id) },
|
|
data: { name, description },
|
|
});
|
|
|
|
return NextResponse.json(site);
|
|
} catch (error) {
|
|
console.error(error);
|
|
return NextResponse.json({ error: "Failed to update site" }, { status: 500 });
|
|
}
|
|
}
|