45 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-04-12 12:33:37 +02:00
import { NextResponse, NextRequest } from "next/server";
2025-04-13 21:10:17 +02:00
import { prisma } from "@/lib/prisma";
2025-04-12 12:33:37 +02:00
interface AddRequest {
host: boolean;
hostServer: number;
2025-04-12 12:33:37 +02:00
name: string;
icon: string;
2025-04-12 12:33:37 +02:00
os: string;
ip: string;
url: string;
2025-04-12 21:00:18 +02:00
cpu: string;
gpu: string;
ram: string;
disk: string;
2025-04-12 12:33:37 +02:00
}
export async function POST(request: NextRequest) {
try {
const body: AddRequest = await request.json();
const { host, hostServer, name, icon, os, ip, url, cpu, gpu, ram, disk } = body;
2025-04-12 12:33:37 +02:00
const server = await prisma.server.create({
data: {
host,
hostServer,
2025-04-12 12:33:37 +02:00
name,
icon,
2025-04-12 12:33:37 +02:00
os,
ip,
url,
2025-04-12 21:00:18 +02:00
cpu,
gpu,
ram,
disk
2025-04-12 12:33:37 +02:00
}
});
return NextResponse.json({ message: "Success", server });
} catch (error: any) {
return NextResponse.json({ error: error.message }, { status: 500 });
}
}