mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
43 lines
1007 B
TypeScript
43 lines
1007 B
TypeScript
import { NextResponse, NextRequest } from "next/server";
|
|
import { prisma } from "@/lib/prisma";
|
|
|
|
interface AddRequest {
|
|
host: boolean;
|
|
hostServer: number;
|
|
name: string;
|
|
os: string;
|
|
ip: string;
|
|
url: string;
|
|
cpu: string;
|
|
gpu: string;
|
|
ram: string;
|
|
disk: string;
|
|
|
|
}
|
|
|
|
export async function POST(request: NextRequest) {
|
|
try {
|
|
const body: AddRequest = await request.json();
|
|
const { host, hostServer, name, os, ip, url, cpu, gpu, ram, disk } = body;
|
|
|
|
const server = await prisma.server.create({
|
|
data: {
|
|
host,
|
|
hostServer,
|
|
name,
|
|
os,
|
|
ip,
|
|
url,
|
|
cpu,
|
|
gpu,
|
|
ram,
|
|
disk
|
|
}
|
|
});
|
|
|
|
return NextResponse.json({ message: "Success", server });
|
|
} catch (error: any) {
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
}
|
|
}
|