mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Server System
This commit is contained in:
31
app/api/servers/add/route.ts
Normal file
31
app/api/servers/add/route.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { NextResponse, NextRequest } from "next/server";
|
||||
import { PrismaClient } from '@/lib/generated/prisma'
|
||||
|
||||
interface AddRequest {
|
||||
name: string;
|
||||
os: string;
|
||||
ip: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body: AddRequest = await request.json();
|
||||
const { name, os, ip, url } = body;
|
||||
|
||||
const server = await prisma.server.create({
|
||||
data: {
|
||||
name,
|
||||
os,
|
||||
ip,
|
||||
url,
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ message: "Success", server });
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user