Deploy app
This commit is contained in:
@@ -2,10 +2,11 @@ import { NextRequest, NextResponse } from "next/server";
|
||||
import testAuth from "../auth";
|
||||
import { StatusCodes } from "http-status-codes";
|
||||
import { deployApp, getDeployments } from "@/core/deployment";
|
||||
import { Application } from "@/lib/types";
|
||||
|
||||
export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
const auth = await testAuth(req);
|
||||
const { name, appId }: { name: string; appId: string } = await req.json();
|
||||
const { name, app }: { name: string; app: Application } = await req.json();
|
||||
|
||||
if (auth) {
|
||||
return NextResponse.json(
|
||||
@@ -14,14 +15,14 @@ export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
);
|
||||
}
|
||||
|
||||
if (!name || !appId) {
|
||||
if (!name || !app) {
|
||||
return NextResponse.json(
|
||||
{ message: "Body missing name, appId, nodeId" },
|
||||
{ status: StatusCodes.BAD_REQUEST }
|
||||
);
|
||||
}
|
||||
|
||||
const deployId = await deployApp(name, appId);
|
||||
const deployId = await deployApp(name, app);
|
||||
|
||||
return NextResponse.json({
|
||||
message: "ok",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import testAuth from "../auth";
|
||||
import { StatusCodes } from "http-status-codes";
|
||||
import { deployApp, getDeployments } from "@/core/deployment";
|
||||
import { getDeployments } from "@/core/deployment";
|
||||
|
||||
export async function POST(req: NextRequest): Promise<NextResponse> {
|
||||
const auth = await testAuth(req);
|
||||
|
||||
@@ -22,11 +22,7 @@ const statusDot = {
|
||||
export default function DeploymentsPage() {
|
||||
const { value: apps } = useAsync([], getApps);
|
||||
|
||||
const { value: deployments, loading } = useAsync(
|
||||
[],
|
||||
async () => (await getDeployments()).filter((d) => d !== null),
|
||||
[apps]
|
||||
);
|
||||
const { value: deployments, loading } = useAsync([], getDeployments, [apps]);
|
||||
|
||||
const appNameByContainer = useMemo(() => {
|
||||
const map = new Map<string, string>();
|
||||
@@ -46,7 +42,9 @@ export default function DeploymentsPage() {
|
||||
{/* Header */}
|
||||
<div className="flex items-center justify-between mb-6">
|
||||
<Badge>
|
||||
{loading ? "Loading…" : `${deployments.length} deployments`}
|
||||
{loading
|
||||
? "Loading…"
|
||||
: `${deployments.length} deployment${deployments.length > 0 && 's'}`}
|
||||
</Badge>
|
||||
|
||||
<DeployAppDialog>
|
||||
|
||||
Reference in New Issue
Block a user