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