Skip to content

Scheduling infrastructure for absolutely everyone.

fix: add optional to pagination query's

Agusti Fernandez Pardo6971ba249f0b
diff --git a/lib/helpers/withPagination.ts b/lib/helpers/withPagination.ts
index d8c68fdd3b5..8e2da388f5e 100644
--- a/lib/helpers/withPagination.ts
+++ b/lib/helpers/withPagination.ts
@@ -5,22 +5,24 @@ const withPage = z.object({
page: z
.string()
.min(1)
+ .optional()
.default("1")
.transform((n) => parseInt(n)),
take: z
.string()
.min(10)
.max(100)
+ .optional()
.default("10")
.transform((n) => parseInt(n)),
});
export const withPagination: NextMiddleware = async (req, _, next) => {
const { page, take } = withPage.parse(req.query);
- const skip = page * take;
+ const skip = page * take || 0;
req.pagination = {
- take: take || 10,
- skip: skip || 0,
+ take,
+ skip,
};
await next();
};