Files
dockship/src/app/api/deploy/route.ts
T
2026-01-03 20:15:58 +01:00

31 lines
794 B
TypeScript

import { NextRequest, NextResponse } from "next/server";
import testAuth from "../auth";
import { StatusCodes } from "http-status-codes";
import { deployApp, getDeployments } from "@/core/deployment";
export async function POST(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
const { name, appId }: { name: string; appId: string } = await req.json();
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
if (!name || !appId) {
return NextResponse.json(
{ message: "Body missing name, appId, nodeId" },
{ status: StatusCodes.BAD_REQUEST }
);
}
const deployId = await deployApp(name, appId);
return NextResponse.json({
message: "ok",
deployId,
});
}