mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
48 lines
1.0 KiB
TypeScript
48 lines
1.0 KiB
TypeScript
import { z } from "zod";
|
|
import {
|
|
getConfig,
|
|
getContainers,
|
|
getContainersByAppLabel,
|
|
getContainersByAppNameMatch,
|
|
} from "../services/docker";
|
|
import { createTRPCRouter, protectedProcedure } from "../trpc";
|
|
|
|
export const dockerRouter = createTRPCRouter({
|
|
getContainers: protectedProcedure.query(async () => {
|
|
return await getContainers();
|
|
}),
|
|
|
|
getConfig: protectedProcedure
|
|
.input(
|
|
z.object({
|
|
containerId: z.string().min(1),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return await getConfig(input.containerId);
|
|
}),
|
|
|
|
getContainersByAppNameMatch: protectedProcedure
|
|
.input(
|
|
z.object({
|
|
appType: z
|
|
.union([z.literal("stack"), z.literal("docker-compose")])
|
|
.optional(),
|
|
appName: z.string().min(1),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return await getContainersByAppNameMatch(input.appName, input.appType);
|
|
}),
|
|
|
|
getContainersByAppLabel: protectedProcedure
|
|
.input(
|
|
z.object({
|
|
appName: z.string().min(1),
|
|
}),
|
|
)
|
|
.query(async ({ input }) => {
|
|
return await getContainersByAppLabel(input.appName);
|
|
}),
|
|
});
|