diff --git a/app/api/sites/add/route.ts b/app/api/sites/add/route.ts new file mode 100644 index 0000000..6c97c3a --- /dev/null +++ b/app/api/sites/add/route.ts @@ -0,0 +1,30 @@ +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 }); + } +} + \ No newline at end of file