28 lines
725 B
TypeScript
Raw Normal View History

2025-05-18 21:11:27 +02:00
import { NextRequest, NextResponse } from "next/server";
import prisma from "@/app/prisma";
2025-05-18 21:50:33 +02:00
import { Network } from "@/app/types";
2025-05-18 21:11:27 +02:00
interface Body {
2025-05-18 21:50:33 +02:00
id: string;
2025-05-18 21:11:27 +02:00
name: string;
description: string;
2025-05-18 21:50:33 +02:00
networks: Network[];
2025-05-18 21:11:27 +02:00
}
export async function POST(request: NextRequest) {
const body: Body = await request.json();
2025-05-18 21:50:33 +02:00
const { id, name, description, networks } = body;
2025-05-18 21:11:27 +02:00
try {
const site = await prisma.site.update({
2025-05-18 21:50:33 +02:00
where: { id: Number(id) },
2025-05-18 21:11:27 +02:00
data: { name, description },
});
return NextResponse.json(site);
} catch (error) {
console.error(error);
return NextResponse.json({ error: "Failed to update site" }, { status: 500 });
}
}