mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-17 15:36:50 +00:00
Add host and hostServer fields to AddRequest and EditRequest interfaces
This commit is contained in:
parent
01470f5ce1
commit
c266296c4f
@ -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,
|
||||||
|
|||||||
@ -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) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user