update server services to support DNS type queries
This commit is contained in:
1 parent
98d2bbfbb9
commit
272e4b5014
4 files changed
+12
-6
No files matched your search
@@ -223,7 +223,8 @@ export class MonitorService implements IMonitorService {
|
|||||||
checksData.monitorType !== "port" &&
|
checksData.monitorType !== "port" &&
|
||||||
checksData.monitorType !== "game" &&
|
checksData.monitorType !== "game" &&
|
||||||
checksData.monitorType !== "grpc" &&
|
checksData.monitorType !== "grpc" &&
|
||||||
checksData.monitorType !== "websocket"
|
checksData.monitorType !== "websocket" &&
|
||||||
|
checksData.monitorType !== "dns"
|
||||||
) {
|
) {
|
||||||
throw new AppError({ message: `${monitor.type} monitors are not supported for uptime details`, status: 400 });
|
throw new AppError({ message: `${monitor.type} monitors are not supported for uptime details`, status: 400 });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export const getChecksParamValidation = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const getChecksQueryValidation = z.object({
|
export const getChecksQueryValidation = z.object({
|
||||||
type: z.enum(["http", "ping", "pagespeed", "hardware", "docker", "port", "game", "grpc", "websocket"]).optional(),
|
type: z.enum(["http", "ping", "pagespeed", "hardware", "docker", "port", "game", "grpc", "websocket", "dns"]).optional(),
|
||||||
sortOrder: z.enum(["asc", "desc"]),
|
sortOrder: z.enum(["asc", "desc"]),
|
||||||
limit: z.coerce.number().optional(),
|
limit: z.coerce.number().optional(),
|
||||||
dateRange: z.enum(["recent", "hour", "day", "week", "month", "all"]),
|
dateRange: z.enum(["recent", "hour", "day", "week", "month", "all"]),
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
import { booleanCoercion } from "./shared.js";
|
import { booleanCoercion, dnsServerValidation } from "./shared.js";
|
||||||
import { GeoContinents } from "@/types/geoCheck.js";
|
import { GeoContinents } from "@/types/geoCheck.js";
|
||||||
import { DnsRecordTypes, MonitorMatchMethods, MonitorStatuses, MonitorTypes } from "@/types/monitor.js";
|
import { DnsRecordTypes, MonitorMatchMethods, MonitorStatuses, MonitorTypes } from "@/types/monitor.js";
|
||||||
|
|
||||||
@@ -68,7 +68,7 @@ export const createMonitorBodyValidation = z.object({
|
|||||||
geoCheckEnabled: z.boolean().optional(),
|
geoCheckEnabled: z.boolean().optional(),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
||||||
geoCheckInterval: z.number().min(300000).optional(),
|
geoCheckInterval: z.number().min(300000).optional(),
|
||||||
dnsServer: z.string().optional(),
|
dnsServer: dnsServerValidation.optional(),
|
||||||
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -99,7 +99,7 @@ export const editMonitorBodyValidation = z.object({
|
|||||||
geoCheckEnabled: z.boolean().optional(),
|
geoCheckEnabled: z.boolean().optional(),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).optional(),
|
||||||
geoCheckInterval: z.number().min(300000).optional(),
|
geoCheckInterval: z.number().min(300000).optional(),
|
||||||
dnsServer: z.string().optional(),
|
dnsServer: dnsServerValidation.optional(),
|
||||||
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -162,7 +162,7 @@ const importedMonitorSchema = z.object({
|
|||||||
geoCheckEnabled: z.boolean().default(false),
|
geoCheckEnabled: z.boolean().default(false),
|
||||||
geoCheckLocations: z.array(z.enum(GeoContinents)).default([]),
|
geoCheckLocations: z.array(z.enum(GeoContinents)).default([]),
|
||||||
geoCheckInterval: z.number().min(300000).default(300000),
|
geoCheckInterval: z.number().min(300000).default(300000),
|
||||||
dnsServer: z.string().optional(),
|
dnsServer: dnsServerValidation.optional(),
|
||||||
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
dnsRecordType: z.enum(DnsRecordTypes).optional(),
|
||||||
createdAt: z.string().optional(),
|
createdAt: z.string().optional(),
|
||||||
updatedAt: z.string().optional(),
|
updatedAt: z.string().optional(),
|
||||||
|
|||||||
@@ -15,6 +15,11 @@ export const nameValidation = z
|
|||||||
|
|
||||||
export const lowercaseEmailValidation = z.email().transform((val) => val.toLowerCase());
|
export const lowercaseEmailValidation = z.email().transform((val) => val.toLowerCase());
|
||||||
|
|
||||||
|
export const dnsServerValidation = z
|
||||||
|
.string()
|
||||||
|
.min(1, "DNS server is required")
|
||||||
|
.refine((v) => z.ipv4().safeParse(v).success || z.ipv6().safeParse(v).success, "Enter a valid IPv4 or IPv6 address (e.g. 8.8.8.8)");
|
||||||
|
|
||||||
export const booleanCoercion = z.preprocess((val) => {
|
export const booleanCoercion = z.preprocess((val) => {
|
||||||
if (val === "true" || val === true) return true;
|
if (val === "true" || val === true) return true;
|
||||||
if (val === "false" || val === false) return false;
|
if (val === "false" || val === false) return false;
|
||||||
|
|||||||
Reference in new issue
Block a user