From 059dc2737bff95c5a55c43de23c9466c32b3c1a3 Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 20 Aug 2026 10:28:50 -0700 Subject: [PATCH] add proxy type and model --- server/src/domain/monitors/monitor.type.ts | 3 ++ server/src/domain/proxies/proxy.model.ts | 38 ++++++++++++++++++++++ server/src/domain/proxies/proxy.type.ts | 15 +++++++++ 3 files changed, 56 insertions(+) create mode 100644 server/src/domain/proxies/proxy.model.ts create mode 100644 server/src/domain/proxies/proxy.type.ts diff --git a/server/src/domain/monitors/monitor.type.ts b/server/src/domain/monitors/monitor.type.ts index 0fb1ed397..73fe63484 100644 --- a/server/src/domain/monitors/monitor.type.ts +++ b/server/src/domain/monitors/monitor.type.ts @@ -41,6 +41,9 @@ export const DefaultPageSpeedStrategy: PageSpeedStrategy = "desktop"; export const GeoCheckSupportedTypes: readonly MonitorType[] = ["http", "ping"] as const; export const supportsGeoCheck = (type: MonitorType): boolean => GeoCheckSupportedTypes.includes(type); +export const ProxyModes = ["inherit", "none", "custom"] as const; +export type ProxyMode = (typeof ProxyModes)[number]; + export const UptimeDetailsSupportedTypes = [ "http", "ping", diff --git a/server/src/domain/proxies/proxy.model.ts b/server/src/domain/proxies/proxy.model.ts new file mode 100644 index 000000000..fbb0b1294 --- /dev/null +++ b/server/src/domain/proxies/proxy.model.ts @@ -0,0 +1,38 @@ +import { Schema, model, type Types } from "mongoose"; +import type { Proxy as ProxyEntity } from "@/domain/proxies/proxy.type.js"; +import { ProxyProtocols } from "@/domain/proxies/proxy.type.js"; + +type ProxyDocumentBase = Omit; + +interface ProxyDocument extends ProxyDocumentBase { + _id: Types.ObjectId; + teamId: Types.ObjectId; + createdAt: Date; + updatedAt: Date; +} + +const ProxySchema = new Schema( + { + teamId: { + type: Schema.Types.ObjectId, + ref: "Team", + immutable: true, + required: true, + }, + name: { type: String, required: true }, + protocol: { type: String, enum: ProxyProtocols, required: true }, + host: { type: String, required: true }, + port: { type: Number, required: true }, + username: { type: String, required: false }, + password: { type: String, required: false }, + }, + { timestamps: true } +); + +ProxySchema.index({ teamId: 1, name: 1 }, { unique: true }); + +const ProxyModel = model("Proxy", ProxySchema); + +export type { ProxyDocument }; +export { ProxyModel }; +export default ProxyModel; diff --git a/server/src/domain/proxies/proxy.type.ts b/server/src/domain/proxies/proxy.type.ts new file mode 100644 index 000000000..a21ab9875 --- /dev/null +++ b/server/src/domain/proxies/proxy.type.ts @@ -0,0 +1,15 @@ +export const ProxyProtocols = ["http", "https"] as const; +export type ProxyProtocol = (typeof ProxyProtocols)[number]; + +export interface Proxy { + id: string; + teamId: string; + name: string; + protocol: ProxyProtocol; + host: string; + port: number; + username?: string; + password?: string; + createdAt: string; + updatedAt: string; +}