mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
refactor: add is cloud to fn
This commit is contained in:
@@ -721,6 +721,12 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
)
|
)
|
||||||
.mutation(async ({ input }) => {
|
.mutation(async ({ input }) => {
|
||||||
try {
|
try {
|
||||||
|
if (IS_CLOUD && !input.serverId) {
|
||||||
|
throw new TRPCError({
|
||||||
|
code: "UNAUTHORIZED",
|
||||||
|
message: "Please set a serverId to update Traefik ports",
|
||||||
|
});
|
||||||
|
}
|
||||||
await initializeTraefik({
|
await initializeTraefik({
|
||||||
serverId: input.serverId,
|
serverId: input.serverId,
|
||||||
additionalPorts: input.additionalPorts,
|
additionalPorts: input.additionalPorts,
|
||||||
@@ -729,7 +735,10 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new TRPCError({
|
throw new TRPCError({
|
||||||
code: "BAD_REQUEST",
|
code: "BAD_REQUEST",
|
||||||
message: "Failed to update Traefik ports",
|
message:
|
||||||
|
error instanceof Error
|
||||||
|
? error.message
|
||||||
|
: "Error to update Traefik ports",
|
||||||
cause: error,
|
cause: error,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -749,12 +758,12 @@ export const settingsRouter = createTRPCRouter({
|
|||||||
stdout = result.stdout;
|
stdout = result.stdout;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ports: Array<{
|
const ports: {
|
||||||
Protocol: string;
|
Protocol: string;
|
||||||
TargetPort: number;
|
TargetPort: number;
|
||||||
PublishedPort: number;
|
PublishedPort: number;
|
||||||
PublishMode: string;
|
PublishMode: string;
|
||||||
}> = JSON.parse(stdout.trim());
|
}[] = JSON.parse(stdout.trim());
|
||||||
|
|
||||||
// Filter out the default ports (80, 443, and optionally 8080)
|
// Filter out the default ports (80, 443, and optionally 8080)
|
||||||
const additionalPorts = ports
|
const additionalPorts = ports
|
||||||
|
|||||||
@@ -16,11 +16,11 @@ interface TraefikOptions {
|
|||||||
enableDashboard?: boolean;
|
enableDashboard?: boolean;
|
||||||
env?: string[];
|
env?: string[];
|
||||||
serverId?: string;
|
serverId?: string;
|
||||||
additionalPorts?: Array<{
|
additionalPorts?: {
|
||||||
targetPort: number;
|
targetPort: number;
|
||||||
publishedPort: number;
|
publishedPort: number;
|
||||||
publishMode?: "ingress" | "host";
|
publishMode?: "ingress" | "host";
|
||||||
}>;
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export const initializeTraefik = async ({
|
export const initializeTraefik = async ({
|
||||||
|
|||||||
Reference in New Issue
Block a user