mirror of
https://github.com/crocofied/CoreControl.git
synced 2025-12-29 16:14:43 +00:00
Add Application API & Functionality
This commit is contained in:
33
app/api/applications/add/route.ts
Normal file
33
app/api/applications/add/route.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { NextResponse, NextRequest } from "next/server";
|
||||
import { PrismaClient } from '@/lib/generated/prisma'
|
||||
|
||||
interface AddRequest {
|
||||
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();
|
||||
const { name, description, icon, publicURL, localURL } = body;
|
||||
|
||||
const application = await prisma.application.create({
|
||||
data: {
|
||||
name,
|
||||
description,
|
||||
icon,
|
||||
publicURL,
|
||||
localURL
|
||||
}
|
||||
});
|
||||
|
||||
return NextResponse.json({ message: "Success", application });
|
||||
} catch (error: any) {
|
||||
return NextResponse.json({ error: error.message }, { status: 500 });
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user