Feat: Frontend - Add websocket to client types and validations

This commit is contained in:
Br0wnHammer committed 2026-03-07 01:00:38 +05:30
1 parent 23247d4319
commit 1d529e3be4
2 files changed
+10

No files matched your search

+1
View File
@@ -9,6 +9,7 @@ export const getMonitorPath = (type: MonitorType): string => {
ping: "uptime", ping: "uptime",
game: "uptime", game: "uptime",
grpc: "uptime", grpc: "uptime",
websocket: "uptime",
unknown: "uptime", unknown: "uptime",
docker: "uptime", docker: "uptime",
hardware: "infrastructure", hardware: "infrastructure",
+9
View File
@@ -115,6 +115,13 @@ const hardwareSchema = baseSchema.extend({
selectedDisks: z.array(z.string()), selectedDisks: z.array(z.string()),
}); });
// WebSocket monitor schema
const websocketSchema = baseSchema.extend({
type: z.literal("websocket"),
url: z.string().min(1, "WebSocket URL is required"),
ignoreTlsErrors: z.boolean(),
});
// Discriminated union of all monitor types // Discriminated union of all monitor types
export const monitorSchema = z.discriminatedUnion("type", [ export const monitorSchema = z.discriminatedUnion("type", [
httpSchema, httpSchema,
@@ -125,6 +132,7 @@ export const monitorSchema = z.discriminatedUnion("type", [
grpcSchema, grpcSchema,
pagespeedSchema, pagespeedSchema,
hardwareSchema, hardwareSchema,
websocketSchema,
]); ]);
export type MonitorFormData = z.infer<typeof monitorSchema>; export type MonitorFormData = z.infer<typeof monitorSchema>;
@@ -139,4 +147,5 @@ export {
grpcSchema, grpcSchema,
pagespeedSchema, pagespeedSchema,
hardwareSchema, hardwareSchema,
websocketSchema,
}; };