implement port monitoring
This commit is contained in:
1 parent
caa863afe8
commit
5d825537ae
10 files changed
+195
-47
No files matched your search
@@ -88,17 +88,50 @@ const optionalString = <T extends z.ZodTypeAny>(schema: T) =>
|
||||
schema.optional()
|
||||
);
|
||||
|
||||
export const monitorSchema = z.object({
|
||||
type: z.string().min(1, "You must select an option"),
|
||||
url: z.string().min(1, "URL is required").regex(urlRegex, "Invalid URL"),
|
||||
n: z.coerce
|
||||
.number({ message: "Number required" })
|
||||
.min(1, "Minimum value is 1")
|
||||
.max(25, "Maximum value is 25"),
|
||||
notificationChannels: z.array(z.string()).optional().default([]),
|
||||
name: z.string().min(1, "Display name is required"),
|
||||
interval: durationSchema,
|
||||
});
|
||||
export const monitorSchema = z
|
||||
.object({
|
||||
type: z.string().min(1, "You must select an option"),
|
||||
url: z.string().min(1, "URL is required").regex(urlRegex, "Invalid URL"),
|
||||
n: z.coerce
|
||||
.number({ message: "Number required" })
|
||||
.min(1, "Minimum value is 1")
|
||||
.max(25, "Maximum value is 25"),
|
||||
port: z.coerce.number().optional(),
|
||||
notificationChannels: z.array(z.string()).optional().default([]),
|
||||
name: z.string().min(1, "Display name is required"),
|
||||
interval: durationSchema,
|
||||
})
|
||||
.superRefine((data, ctx) => {
|
||||
if (data.type === "port") {
|
||||
if (!data.port) {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: "Port is required for port monitoring",
|
||||
path: ["port"],
|
||||
});
|
||||
}
|
||||
if (isNaN(Number(data.port))) {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: "Port must be a number",
|
||||
path: ["port"],
|
||||
});
|
||||
}
|
||||
if (Number(data.port) < 1 || Number(data.port) > 65535) {
|
||||
ctx.addIssue({
|
||||
code: "custom",
|
||||
message: "Port must be between 1 and 65535",
|
||||
path: ["port"],
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.transform((data) => {
|
||||
if (data.type !== "port") {
|
||||
return { ...data, port: undefined };
|
||||
}
|
||||
return data;
|
||||
});
|
||||
|
||||
export const monitorSchemaPageSpeed = z.object({
|
||||
type: z.string().min(1, "You must select an option"),
|
||||
@@ -212,13 +245,9 @@ export const maintenanceSchema = z
|
||||
|
||||
export const systemSettingsSchema = z.object({
|
||||
systemEmailHost: optionalString(
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.min(1, { message: "SMTP host is required" })
|
||||
.max(255, {
|
||||
message: "SMTP host must be 255 characters or fewer",
|
||||
})
|
||||
z.string().trim().min(1, { message: "SMTP host is required" }).max(255, {
|
||||
message: "SMTP host must be 255 characters or fewer",
|
||||
})
|
||||
),
|
||||
systemEmailPort: optionalString(
|
||||
z
|
||||
@@ -237,35 +266,24 @@ export const systemSettingsSchema = z.object({
|
||||
z.string().email({ message: "SMTP email must be valid" })
|
||||
),
|
||||
systemEmailPassword: optionalString(
|
||||
z
|
||||
.string()
|
||||
.max(255, {
|
||||
message: "SMTP password must be 255 characters or fewer",
|
||||
})
|
||||
z.string().max(255, {
|
||||
message: "SMTP password must be 255 characters or fewer",
|
||||
})
|
||||
),
|
||||
systemEmailUser: optionalString(
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.max(255, {
|
||||
message: "SMTP username must be 255 characters or fewer",
|
||||
})
|
||||
z.string().trim().max(255, {
|
||||
message: "SMTP username must be 255 characters or fewer",
|
||||
})
|
||||
),
|
||||
systemEmailConnectionHost: optionalString(
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.max(255, {
|
||||
message: "Connection host must be 255 characters or fewer",
|
||||
})
|
||||
z.string().trim().max(255, {
|
||||
message: "Connection host must be 255 characters or fewer",
|
||||
})
|
||||
),
|
||||
systemEmailTLSServername: optionalString(
|
||||
z
|
||||
.string()
|
||||
.trim()
|
||||
.max(255, {
|
||||
message: "TLS server name must be 255 characters or fewer",
|
||||
})
|
||||
z.string().trim().max(255, {
|
||||
message: "TLS server name must be 255 characters or fewer",
|
||||
})
|
||||
),
|
||||
systemEmailSecure: z.boolean().optional(),
|
||||
systemEmailPool: z.boolean().optional(),
|
||||
|
||||
Reference in new issue
Block a user