add proxy type and model
This commit is contained in:
1 parent
158f2fffbe
commit
059dc2737b
3 files changed
+56
No files matched your search
@@ -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",
|
||||
|
||||
@@ -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<ProxyEntity, "id" | "teamId" | "createdAt" | "updatedAt">;
|
||||
|
||||
interface ProxyDocument extends ProxyDocumentBase {
|
||||
_id: Types.ObjectId;
|
||||
teamId: Types.ObjectId;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
const ProxySchema = new Schema<ProxyDocument>(
|
||||
{
|
||||
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<ProxyDocument>("Proxy", ProxySchema);
|
||||
|
||||
export type { ProxyDocument };
|
||||
export { ProxyModel };
|
||||
export default ProxyModel;
|
||||
@@ -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;
|
||||
}
|
||||
Reference in new issue
Block a user