mirror of
https://github.com/Dokploy/dokploy.git
synced 2026-06-28 10:35:21 +02:00
- Introduced new test files for permission checks, including `check-permission.test.ts`, `enterprise-only-resources.test.ts`, `resolve-permissions.test.ts`, and `service-access.test.ts`. - Implemented permission checks in various components to ensure actions are gated by user permissions, including `ShowTraefikConfig`, `UpdateTraefikConfig`, `ShowVolumes`, `ShowDomains`, and others. - Enhanced the logic for displaying UI elements based on user permissions, ensuring that only authorized users can access or modify resources.
58 lines
1.3 KiB
TypeScript
58 lines
1.3 KiB
TypeScript
import {
|
|
getApplicationInfo,
|
|
getNodeApplications,
|
|
getNodeInfo,
|
|
getSwarmNodes,
|
|
} from "@dokploy/server";
|
|
import { z } from "zod";
|
|
import { createTRPCRouter, withPermission } from "../trpc";
|
|
import { containerIdRegex } from "./docker";
|
|
|
|
export const swarmRouter = createTRPCRouter({
|
|
getNodes: withPermission("server", "read")
|
|
.input(
|
|
z.object({
|
|
serverId: z.string().optional(),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return await getSwarmNodes(input.serverId);
|
|
}),
|
|
getNodeInfo: withPermission("server", "read")
|
|
.input(z.object({ nodeId: z.string(), serverId: z.string().optional() }))
|
|
.query(async ({ input }) => {
|
|
return await getNodeInfo(input.nodeId, input.serverId);
|
|
}),
|
|
getNodeApps: withPermission("server", "read")
|
|
.input(
|
|
z.object({
|
|
serverId: z.string().optional(),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return getNodeApplications(input.serverId);
|
|
}),
|
|
getAppInfos: withPermission("server", "read")
|
|
.meta({
|
|
openapi: {
|
|
path: "/drop-deployment",
|
|
method: "POST",
|
|
override: true,
|
|
enabled: false,
|
|
},
|
|
})
|
|
.input(
|
|
z.object({
|
|
appName: z
|
|
.string()
|
|
.min(1)
|
|
.regex(containerIdRegex, "Invalid app name.")
|
|
.array(),
|
|
serverId: z.string().optional(),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return await getApplicationInfo(input.appName, input.serverId);
|
|
}),
|
|
});
|