Add prefix to ui and resource

This commit is contained in:
Owen
2025-09-11 21:20:33 -07:00
parent 2551e0c291
commit d51e7f7e40
8 changed files with 280 additions and 17 deletions

View File

@@ -98,7 +98,9 @@ export async function updateResources(
method: targetData.method,
port: targetData.port,
enabled: targetData.enabled,
internalPort: internalPortToCreate
internalPort: internalPortToCreate,
path: targetData.path,
pathMatchType: targetData.pathMatchType
})
.returning();
@@ -121,6 +123,7 @@ export async function updateResources(
const protocol =
resourceData.protocol == "http" ? "tcp" : resourceData.protocol;
const resourceEnabled = resourceData.enabled == undefined || resourceData.enabled == null ? true : resourceData.enabled;
const resourceSsl = resourceData.ssl == undefined || resourceData.ssl == null ? true : resourceData.ssl;
let headers = "";
for (const headerObj of resourceData.headers || []) {
for (const [key, value] of Object.entries(headerObj)) {
@@ -165,7 +168,7 @@ export async function updateResources(
domainId: domain ? domain.domainId : null,
enabled: resourceEnabled,
sso: resourceData.auth?.["sso-enabled"] || false,
ssl: resourceData.ssl ? true : false,
ssl: resourceSsl,
setHostHeader: resourceData["host-header"] || null,
tlsServerName: resourceData["tls-server-name"] || null,
emailWhitelistEnabled: resourceData.auth?.[
@@ -311,7 +314,9 @@ export async function updateResources(
ip: targetData.hostname,
method: http ? targetData.method : null,
port: targetData.port,
enabled: targetData.enabled
enabled: targetData.enabled,
path: targetData.path,
pathMatchType: targetData.pathMatchType
})
.where(eq(targets.targetId, existingTarget.targetId))
.returning();
@@ -395,7 +400,7 @@ export async function updateResources(
sso: resourceData.auth?.["sso-enabled"] || false,
setHostHeader: resourceData["host-header"] || null,
tlsServerName: resourceData["tls-server-name"] || null,
ssl: resourceData.ssl ? true : false,
ssl: resourceSsl,
headers: headers || null
})
.returning();

View File

@@ -13,6 +13,8 @@ export const TargetSchema = z.object({
port: z.number().int().min(1).max(65535),
enabled: z.boolean().optional().default(true),
"internal-port": z.number().int().min(1).max(65535).optional(),
path: z.string().optional(),
pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable()
});
export type TargetData = z.infer<typeof TargetSchema>;

View File

@@ -30,7 +30,9 @@ const createTargetSchema = z
ip: z.string().refine(isTargetValid),
method: z.string().optional().nullable(),
port: z.number().int().min(1).max(65535),
enabled: z.boolean().default(true)
enabled: z.boolean().default(true),
path: z.string().optional().nullable(),
pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable()
})
.strict();

View File

@@ -44,7 +44,9 @@ function queryTargets(resourceId: number) {
enabled: targets.enabled,
resourceId: targets.resourceId,
siteId: targets.siteId,
siteType: sites.type
siteType: sites.type,
path: targets.path,
pathMatchType: targets.pathMatchType
})
.from(targets)
.leftJoin(sites, eq(sites.siteId, targets.siteId))

View File

@@ -26,7 +26,9 @@ const updateTargetBodySchema = z
ip: z.string().refine(isTargetValid),
method: z.string().min(1).max(10).optional().nullable(),
port: z.number().int().min(1).max(65535).optional(),
enabled: z.boolean().optional()
enabled: z.boolean().optional(),
path: z.string().optional().nullable(),
pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable()
})
.strict()
.refine((data) => Object.keys(data).length > 0, {