Deploy to node

This commit is contained in:
2025-12-30 14:46:57 +01:00
parent fb05b455d5
commit a0e04f7fbe
3 changed files with 104 additions and 62 deletions
+28 -1
View File
@@ -1,7 +1,7 @@
import { NextRequest, NextResponse } from "next/server";
import testAuth from "../auth";
import { StatusCodes } from "http-status-codes";
import { getApplications } from "@/core/server/application";
import { deployNewApp, getApplications } from "@/core/server/application";
export async function GET(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
@@ -20,3 +20,30 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
applications,
});
}
export async function POST(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
const { name, repo, nodeId }: { name: string; repo: string; nodeId: string } =
await req.json();
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
if ((!name && !repo) || !nodeId) {
return NextResponse.json(
{ message: "Body missing name, repo, nodeId" },
{ status: StatusCodes.BAD_REQUEST }
);
}
const res = await deployNewApp(name, repo, nodeId);
return NextResponse.json({
message: "ok",
...res,
});
}