Add host and hostServer fields to AddRequest and EditRequest interfaces

This commit is contained in:
headlessdev 2025-04-18 12:26:13 +02:00
parent 01470f5ce1
commit c266296c4f
2 changed files with 8 additions and 2 deletions

View File

@ -2,6 +2,8 @@ import { NextResponse, NextRequest } from "next/server";
import { prisma } from "@/lib/prisma"; import { prisma } from "@/lib/prisma";
interface AddRequest { interface AddRequest {
host: boolean;
hostServer: number;
name: string; name: string;
os: string; os: string;
ip: string; ip: string;
@ -16,10 +18,12 @@ interface AddRequest {
export async function POST(request: NextRequest) { export async function POST(request: NextRequest) {
try { try {
const body: AddRequest = await request.json(); const body: AddRequest = await request.json();
const { name, os, ip, url, cpu, gpu, ram, disk } = body; const { host, hostServer, name, os, ip, url, cpu, gpu, ram, disk } = body;
const server = await prisma.server.create({ const server = await prisma.server.create({
data: { data: {
host,
hostServer,
name, name,
os, os,
ip, ip,

View File

@ -2,6 +2,8 @@ import { NextResponse, NextRequest } from "next/server";
import { prisma } from "@/lib/prisma"; import { prisma } from "@/lib/prisma";
interface EditRequest { interface EditRequest {
host: boolean;
hostServer: number;
id: number; id: number;
name: string; name: string;
os: string; os: string;
@ -16,7 +18,7 @@ interface EditRequest {
export async function PUT(request: NextRequest) { export async function PUT(request: NextRequest) {
try { try {
const body: EditRequest = await request.json(); const body: EditRequest = await request.json();
const { id, name, os, ip, url, cpu, gpu, ram, disk } = body; const { host, hostServer, id, name, os, ip, url, cpu, gpu, ram, disk } = body;
const existingServer = await prisma.server.findUnique({ where: { id } }); const existingServer = await prisma.server.findUnique({ where: { id } });
if (!existingServer) { if (!existingServer) {