Removed app structure from the core

This commit is contained in:
2026-01-03 19:07:54 +01:00
parent 7e5289ae22
commit 6da3c1a0be
6 changed files with 4 additions and 335 deletions
-74
View File
@@ -1,74 +0,0 @@
import { NextRequest, NextResponse } from "next/server";
import testAuth from "../auth";
import { StatusCodes } from "http-status-codes";
import { installApp, getApplications, removeApp } from "@/core/application";
export async function GET(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
const applications = await getApplications();
return NextResponse.json({
message: "ok",
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 installApp(name, repo, nodeId);
return NextResponse.json({
message: "ok",
...res,
});
}
export async function DELETE(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
const appId = req.nextUrl.searchParams.get("appId");
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
if (!appId) {
return NextResponse.json(
{ message: "Missing param appId" },
{ status: StatusCodes.BAD_REQUEST }
);
}
await removeApp(appId);
return NextResponse.json({
message: "ok",
});
}
+2 -3
View File
@@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from "next/server";
import testAuth from "../auth";
import { StatusCodes } from "http-status-codes";
import { deployApp, getDeployments } from "@/core/deployment";
import { getApplications } from "@/core/application";
export async function GET(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
@@ -14,9 +13,9 @@ export async function GET(req: NextRequest): Promise<NextResponse> {
);
}
const apps = await getApplications();
// const apps = await getApplications();
const applications = await getDeployments(apps);
const applications = await getDeployments([]);
return NextResponse.json({
message: "ok",
-41
View File
@@ -1,41 +0,0 @@
import { NextRequest, NextResponse } from "next/server";
import testAuth from "../auth";
import { StatusCodes } from "http-status-codes";
import { getEnv, setEnv } from "@/core/application";
export async function GET(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
return NextResponse.json(await getEnv());
}
export async function POST(req: NextRequest): Promise<NextResponse> {
const auth = await testAuth(req);
if (auth) {
return NextResponse.json(
{ message: auth },
{ status: StatusCodes.UNAUTHORIZED }
);
}
const { appId, variables } = await req.json();
if (!appId || !variables) {
return NextResponse.json(
{ message: "Missing appId, variables in body" },
{ status: StatusCodes.BAD_REQUEST }
);
}
await setEnv(appId, variables);
return NextResponse.json({ message: "ok", success: true });
}
-87
View File
@@ -1,87 +0,0 @@
"use client";
import { DashboardLayout } from "@/components/dashboard/DashboardLayout";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { MoreVertical, Plus, Rocket } from "lucide-react";
import InstallApplicationDialog from "@/components/dialogs/InstallApplication";
import { getApplications, removeApp } from "@/lib/dockship/application";
import RemoveDialog from "@/components/dialogs/Remove";
import DeployAppDialog from "@/components/dialogs/DeployApp";
import { useAsyncInterval } from "@/hooks/use-async";
export default function ApplicationsPage() {
const { value: applications, setValue: setApplications } = useAsyncInterval(
[],
getApplications,
3000
);
const remove = async (appId: string) => {
await removeApp(appId);
setApplications((prev) => prev.filter((app) => app.id !== appId));
};
return (
<DashboardLayout
title="Applications"
subtitle="Manage installed applications"
>
{/* Header */}
<div className="flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between mb-6">
<div className="flex flex-wrap items-center gap-2">
<Badge>{applications.length} apps</Badge>
</div>
<InstallApplicationDialog>
<Button size="sm" className="gap-2 w-full sm:w-auto">
<Plus className="w-4 h-4" /> Install Application
</Button>
</InstallApplicationDialog>
</div>
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
{applications.map((app) => (
<Card key={app.id}>
<CardHeader>
<CardTitle>{app.name}</CardTitle>
<CardDescription>{app.repo}</CardDescription>
</CardHeader>
<CardContent className="flex flex-col gap-2">
{/* Deployments */}
<div className="flex justify-between items-center">
<span className="text-xs text-muted-foreground">
Deployments
</span>
<span className="font-mono text-sm">
{app.deployments?.length ?? 0}
</span>
</div>
</CardContent>
<CardFooter className="justify-end">
<DeployAppDialog defaultApp={app.id}>
<Button variant="ghost" size="icon-sm" aria-label="Deploy">
<Rocket className="w-3 h-3" />
</Button>
</DeployAppDialog>
<RemoveDialog remove={() => remove(app.id)} />
<Button variant="ghost" size="icon-sm" aria-label="More options">
<MoreVertical className="w-3 h-3" />
</Button>
</CardFooter>
</Card>
))}
</div>
</DashboardLayout>
);
}