mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-18 07:56:57 +00:00
30 lines
761 B
TypeScript
30 lines
761 B
TypeScript
|
|
import { NextRequest, NextResponse } from "next/server";
|
||
|
|
import prisma from "@/app/prisma";
|
||
|
|
|
||
|
|
interface Body {
|
||
|
|
name: string;
|
||
|
|
description: string;
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function POST(request: NextRequest) {
|
||
|
|
try {
|
||
|
|
const body: Body = await request.json();
|
||
|
|
|
||
|
|
if (!body.name) {
|
||
|
|
return NextResponse.json({ error: "Missing required fields" }, { status: 400 });
|
||
|
|
}
|
||
|
|
|
||
|
|
const site = await prisma.site.create({
|
||
|
|
data: {
|
||
|
|
name: body.name,
|
||
|
|
description: body.description,
|
||
|
|
},
|
||
|
|
});
|
||
|
|
|
||
|
|
return NextResponse.json({ site }, { status: 201 });
|
||
|
|
|
||
|
|
} catch (error: any) {
|
||
|
|
return NextResponse.json({ error: "Internal Server Error" }, { status: 500 });
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|