feat: add swarm overview for servers

This commit is contained in:
Mauricio Siu
2024-12-23 00:03:30 -06:00
parent 5c5066bc72
commit 6afd443257
12 changed files with 211 additions and 286 deletions

View File

@@ -8,24 +8,37 @@ import { z } from "zod";
import { createTRPCRouter, protectedProcedure } from "../trpc";
export const swarmRouter = createTRPCRouter({
getNodes: protectedProcedure.query(async () => {
return await getSwarmNodes();
}),
getNodeInfo: protectedProcedure
.input(z.object({ nodeId: z.string() }))
getNodes: protectedProcedure
.input(
z.object({
serverId: z.string().optional(),
}),
)
.query(async ({ input }) => {
return await getNodeInfo(input.nodeId);
return await getSwarmNodes(input.serverId);
}),
getNodeInfo: protectedProcedure
.input(z.object({ nodeId: z.string(), serverId: z.string().optional() }))
.query(async ({ input }) => {
return await getNodeInfo(input.nodeId, input.serverId);
}),
getNodeApps: protectedProcedure
.input(
z.object({
serverId: z.string().optional(),
}),
)
.query(async ({ input }) => {
return getNodeApplications(input.serverId);
}),
getNodeApps: protectedProcedure.query(async () => {
return getNodeApplications();
}),
getAppInfos: protectedProcedure
.input(
z.object({
appName: z.string(),
serverId: z.string().optional(),
}),
)
.query(async ({ input }) => {
return await getApplicationInfo(input.appName);
return await getApplicationInfo(input.appName, input.serverId);
}),
});