GeezerVison is showing github.com — perf(webapp): clamp list-endpoint page size to 100 · triggerdotdev/trigger.dev@350c680
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboard +6Lines changed: 6 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +--- | | 2 | +area: webapp | | 3 | +type: improvement | | 4 | +--- | | 5 | + | | 6 | +List API endpoints now clamp the page size to a maximum of 100. Requests asking for a larger page size return up to 100 items and keep paginating, rather than pulling an unbounded page. |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/admin.api.v1.environments.$environmentId.engine.report.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -13,7 +13,12 @@ const ParamsSchema = z.object({ | 13 | 13 | const SearchParamsSchema = z.object({ | 14 | 14 | verbose: z.string().default("0"), | 15 | 15 | page: z.coerce.number().optional(), | 16 | | - per_page: z.coerce.number().optional(), | | 16 | + per_page: z.coerce | | 17 | + .number() | | 18 | + .int() | | 19 | + .positive() | | 20 | + .transform((n) => Math.min(n, 100)) | | 21 | + .optional(), | 17 | 22 | }); | 18 | 23 |
| 19 | 24 | export async function loader({ request, params }: LoaderFunctionArgs) { | |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/admin.api.v1.llm-models.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,10 @@ export async function loader({ request }: LoaderFunctionArgs) { | 9 | 9 |
| 10 | 10 | const url = new URL(request.url); | 11 | 11 | const page = parseInt(url.searchParams.get("page") ?? "1"); | 12 | | - const pageSize = parseInt(url.searchParams.get("pageSize") ?? "50"); | | 12 | + const pageSize = Math.max( | | 13 | + 1, | | 14 | + Math.min(parseInt(url.searchParams.get("pageSize") ?? "50") || 50, 100) | | 15 | + ); | 13 | 16 |
| 14 | 17 | const [models, total] = await Promise.all([ | 15 | 18 | prisma.llmModel.findMany({ | |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/api.v1.queues.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,12 @@ import { ServiceValidationError } from "~/v3/services/baseService.server"; | 12 | 12 |
| 13 | 13 | const SearchParamsSchema = z.object({ | 14 | 14 | page: z.coerce.number().int().positive().optional(), | 15 | | - perPage: z.coerce.number().int().positive().optional(), | | 15 | + perPage: z.coerce | | 16 | + .number() | | 17 | + .int() | | 18 | + .positive() | | 19 | + .transform((n) => Math.min(n, 100)) | | 20 | + .optional(), | 16 | 21 | }); | 17 | 22 |
| 18 | 23 | export const loader = createLoaderApiRoute( | |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/api.v1.schedules.ts +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -12,7 +12,12 @@ import { UpsertTaskScheduleService } from "~/v3/services/upsertTaskSchedule.serv | 12 | 12 |
| 13 | 13 | const SearchParamsSchema = z.object({ | 14 | 14 | page: z.coerce.number().int().positive().optional(), | 15 | | - perPage: z.coerce.number().int().positive().optional(), | | 15 | + perPage: z.coerce | | 16 | + .number() | | 17 | + .int() | | 18 | + .positive() | | 19 | + .transform((n) => Math.min(n, 100)) | | 20 | + .optional(), | 16 | 21 | }); | 17 | 22 |
| 18 | 23 | export async function action({ request }: ActionFunctionArgs) { | |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.queues.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,11 @@ import { EnvironmentParamSchema } from "~/utils/pathBuilder"; | 9 | 9 | const SearchParamsSchema = z.object({ | 10 | 10 | query: z.string().optional(), | 11 | 11 | page: z.coerce.number().min(1).default(1), | 12 | | - per_page: z.coerce.number().min(1).default(20), | | 12 | + per_page: z.coerce | | 13 | + .number() | | 14 | + .min(1) | | 15 | + .transform((n) => Math.min(n, 100)) | | 16 | + .default(20), | 13 | 17 | type: z.enum(["task", "custom"]).optional(), | 14 | 18 | }); | 15 | 19 |
| |
Collapse file Copy file name to clipboardExpand all lines: apps/webapp/app/routes/resources.orgs.$organizationSlug.projects.$projectParam.env.$envParam.versions.ts +5-1Lines changed: 5 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -8,7 +8,11 @@ import { EnvironmentParamSchema } from "~/utils/pathBuilder"; | 8 | 8 |
| 9 | 9 | const SearchParamsSchema = z.object({ | 10 | 10 | query: z.string().optional(), | 11 | | - per_page: z.coerce.number().min(1).default(25), | | 11 | + per_page: z.coerce | | 12 | + .number() | | 13 | + .min(1) | | 14 | + .transform((n) => Math.min(n, 100)) | | 15 | + .default(25), | 12 | 16 | }); | 13 | 17 |
| 14 | 18 | export async function loader({ request, params }: LoaderFunctionArgs) { | |
|