Remove deployment

This commit is contained in:
2026-02-15 17:40:24 +01:00
parent e4060d0fba
commit f700ccb855
4 changed files with 78 additions and 3 deletions
+30 -1
View File
@@ -1,7 +1,11 @@
import { NextRequest, NextResponse } from "next/server";
import testAuth from "../../../lib/server/auth";
import { StatusCodes } from "http-status-codes";
import { deployApp, toggleDeployment } from "@/core/deployment";
import {
deployApp,
removeDeployment,
toggleDeployment,
} from "@/core/deployment";
import { Application, Port } from "@/lib/types";
export async function POST(req: NextRequest): Promise<NextResponse> {
@@ -59,3 +63,28 @@ export async function PUT(req: NextRequest): Promise<NextResponse> {
message: "ok",
});
}
export async function DELETE(req: NextRequest): Promise<NextResponse> {
const deployId = req.nextUrl.searchParams.get("deployId");
const auth = await testAuth(req);
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED },
);
}
if (!deployId) {
return NextResponse.json(
{ message: "Body missing deployId" },
{ status: StatusCodes.BAD_REQUEST },
);
}
await removeDeployment(deployId);
return NextResponse.json({
message: "ok",
});
}