mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Server Hardware Information
This commit is contained in:
@@ -6,6 +6,11 @@ interface AddRequest {
|
||||
os: string;
|
||||
ip: string;
|
||||
url: string;
|
||||
cpu: string;
|
||||
gpu: string;
|
||||
ram: string;
|
||||
disk: string;
|
||||
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@@ -13,7 +18,7 @@ const prisma = new PrismaClient();
|
||||
export async function POST(request: NextRequest) {
|
||||
try {
|
||||
const body: AddRequest = await request.json();
|
||||
const { name, os, ip, url } = body;
|
||||
const { name, os, ip, url, cpu, gpu, ram, disk } = body;
|
||||
|
||||
const server = await prisma.server.create({
|
||||
data: {
|
||||
@@ -21,6 +26,10 @@ export async function POST(request: NextRequest) {
|
||||
os,
|
||||
ip,
|
||||
url,
|
||||
cpu,
|
||||
gpu,
|
||||
ram,
|
||||
disk
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -7,6 +7,10 @@ interface EditRequest {
|
||||
os: string;
|
||||
ip: string;
|
||||
url: string;
|
||||
cpu: string;
|
||||
gpu: string;
|
||||
ram: string;
|
||||
disk: string;
|
||||
}
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
@@ -14,7 +18,7 @@ const prisma = new PrismaClient();
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
const body: EditRequest = await request.json();
|
||||
const { id, name, os, ip, url } = body;
|
||||
const { id, name, os, ip, url, cpu, gpu, ram, disk } = body;
|
||||
|
||||
const existingServer = await prisma.server.findUnique({ where: { id } });
|
||||
if (!existingServer) {
|
||||
@@ -23,7 +27,16 @@ export async function PUT(request: NextRequest) {
|
||||
|
||||
const updatedServer = await prisma.server.update({
|
||||
where: { id },
|
||||
data: { name, os, ip, url }
|
||||
data: {
|
||||
name,
|
||||
os,
|
||||
ip,
|
||||
url,
|
||||
cpu,
|
||||
gpu,
|
||||
ram,
|
||||
disk
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ message: "Server updated", server: updatedServer });
|
||||
|
||||
Reference in New Issue
Block a user