Merge pull request #1592 from Pallavikumarimdb/ordered-priority-in-path-routing-rules

Add ordered priority for path-based routing rules
This commit is contained in:
Owen Schwartz
2025-10-05 17:10:26 -07:00
committed by GitHub
11 changed files with 199 additions and 38 deletions

View File

@@ -53,7 +53,8 @@ const createTargetSchema = z
path: z.string().optional().nullable(),
pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable(),
rewritePath: z.string().optional().nullable(),
rewritePathType: z.enum(["exact", "prefix", "regex", "stripPrefix"]).optional().nullable()
rewritePathType: z.enum(["exact", "prefix", "regex", "stripPrefix"]).optional().nullable(),
priority: z.number().int().min(1).max(1000)
})
.strict();
@@ -210,7 +211,10 @@ export async function createTarget(
internalPort,
enabled: targetData.enabled,
path: targetData.path,
pathMatchType: targetData.pathMatchType
pathMatchType: targetData.pathMatchType,
rewritePath: targetData.rewritePath,
rewritePathType: targetData.rewritePathType,
priority: targetData.priority
})
.returning();

View File

@@ -62,7 +62,8 @@ function queryTargets(resourceId: number) {
path: targets.path,
pathMatchType: targets.pathMatchType,
rewritePath: targets.rewritePath,
rewritePathType: targets.rewritePathType
rewritePathType: targets.rewritePathType,
priority: targets.priority,
})
.from(targets)
.leftJoin(sites, eq(sites.siteId, targets.siteId))

View File

@@ -50,7 +50,8 @@ const updateTargetBodySchema = z
path: z.string().optional().nullable(),
pathMatchType: z.enum(["exact", "prefix", "regex"]).optional().nullable(),
rewritePath: z.string().optional().nullable(),
rewritePathType: z.enum(["exact", "prefix", "regex", "stripPrefix"]).optional().nullable()
rewritePathType: z.enum(["exact", "prefix", "regex", "stripPrefix"]).optional().nullable(),
priority: z.number().int().min(1).max(1000).optional(),
})
.strict()
.refine((data) => Object.keys(data).length > 0, {
@@ -198,7 +199,10 @@ export async function updateTarget(
internalPort,
enabled: parsedBody.data.enabled,
path: parsedBody.data.path,
pathMatchType: parsedBody.data.pathMatchType
pathMatchType: parsedBody.data.pathMatchType,
priority: parsedBody.data.priority,
rewritePath: parsedBody.data.rewritePath,
rewritePathType: parsedBody.data.rewritePathType
})
.where(eq(targets.targetId, targetId))
.returning();