Remove deployment
This commit is contained in:
@@ -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",
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user