mirror of
https://github.com/Dokploy/dokploy
synced 2025-06-26 18:27:59 +00:00
- Extend domain configuration to support custom certificate resolvers - Add new "custom" certificate type option in domain forms - Update database schema and validation to include custom certificate resolver - Implement custom certificate resolver handling in Traefik and Docker domain configurations - Enhance domain management with more flexible SSL/TLS certificate options
65 lines
1.8 KiB
TypeScript
65 lines
1.8 KiB
TypeScript
import { z } from "zod";
|
|
|
|
export const domain = z
|
|
.object({
|
|
host: z.string().min(1, { message: "Add a hostname" }),
|
|
path: z.string().min(1).optional(),
|
|
port: z
|
|
.number()
|
|
.min(1, { message: "Port must be at least 1" })
|
|
.max(65535, { message: "Port must be 65535 or below" })
|
|
.optional(),
|
|
https: z.boolean().optional(),
|
|
certificateType: z.enum(["letsencrypt", "none", "custom"]).optional(),
|
|
customCertResolver: z.string(),
|
|
})
|
|
.superRefine((input, ctx) => {
|
|
if (input.https && !input.certificateType) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ["certificateType"],
|
|
message: "Required",
|
|
});
|
|
}
|
|
|
|
if (input.certificateType === "custom" && !input.customCertResolver) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ["customCertResolver"],
|
|
message: "Required when certificate type is custom",
|
|
});
|
|
}
|
|
});
|
|
|
|
export const domainCompose = z
|
|
.object({
|
|
host: z.string().min(1, { message: "Host is required" }),
|
|
path: z.string().min(1).optional(),
|
|
port: z
|
|
.number()
|
|
.min(1, { message: "Port must be at least 1" })
|
|
.max(65535, { message: "Port must be 65535 or below" })
|
|
.optional(),
|
|
https: z.boolean().optional(),
|
|
certificateType: z.enum(["letsencrypt", "none", "custom"]).optional(),
|
|
customCertResolver: z.string(),
|
|
serviceName: z.string().min(1, { message: "Service name is required" }),
|
|
})
|
|
.superRefine((input, ctx) => {
|
|
if (input.https && !input.certificateType) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ["certificateType"],
|
|
message: "Required",
|
|
});
|
|
}
|
|
|
|
if (input.certificateType === "custom" && !input.customCertResolver) {
|
|
ctx.addIssue({
|
|
code: z.ZodIssueCode.custom,
|
|
path: ["customCertResolver"],
|
|
message: "Required when certificate type is custom",
|
|
});
|
|
}
|
|
});
|