2025-04-11 17:35:06 +02:00
|
|
|
import { NextResponse, NextRequest } from "next/server";
|
|
|
|
|
import { PrismaClient } from '@/lib/generated/prisma'
|
|
|
|
|
|
|
|
|
|
interface AddRequest {
|
2025-04-12 13:19:52 +02:00
|
|
|
serverId: number;
|
2025-04-11 17:35:06 +02:00
|
|
|
name: string;
|
|
|
|
|
description: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
publicURL: string;
|
|
|
|
|
localURL: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
|
|
|
|
|
|
export async function POST(request: NextRequest) {
|
|
|
|
|
try {
|
|
|
|
|
const body: AddRequest = await request.json();
|
2025-04-12 13:19:52 +02:00
|
|
|
const { serverId, name, description, icon, publicURL, localURL } = body;
|
2025-04-11 17:35:06 +02:00
|
|
|
|
|
|
|
|
const application = await prisma.application.create({
|
|
|
|
|
data: {
|
2025-04-12 13:19:52 +02:00
|
|
|
serverId,
|
2025-04-11 17:35:06 +02:00
|
|
|
name,
|
|
|
|
|
description,
|
|
|
|
|
icon,
|
|
|
|
|
publicURL,
|
|
|
|
|
localURL
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return NextResponse.json({ message: "Success", application });
|
|
|
|
|
} catch (error: any) {
|
|
|
|
|
return NextResponse.json({ error: error.message }, { status: 500 });
|
|
|
|
|
}
|
|
|
|
|
}
|