mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-22 09:56:58 +00:00
Edit Application API Route
This commit is contained in:
parent
7023723a16
commit
130e282cd6
38
app/api/applications/edit/route.ts
Normal file
38
app/api/applications/edit/route.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { NextResponse, NextRequest } from "next/server";
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
interface EditRequest {
|
||||
id: number;
|
||||
name: string;
|
||||
description: string;
|
||||
icon: string;
|
||||
publicURL: string;
|
||||
localURL: string;
|
||||
}
|
||||
|
||||
export async function PUT(request: NextRequest) {
|
||||
try {
|
||||
const body: EditRequest = await request.json();
|
||||
const { id, name, description, icon, publicURL, localURL } = body;
|
||||
|
||||
const existingServer = await prisma.server.findUnique({ where: { id } });
|
||||
if (!existingServer) {
|
||||
return NextResponse.json({ error: "Server not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const updatedApplication = await prisma.application.update({
|
||||
where: { id },
|
||||
data: {
|
||||
name,
|
||||
description,
|
||||
icon,
|
||||
publicURL,
|
||||
localURL
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ message: "Application updated", application: updatedApplication });
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user