fix: rename pageNumber to page

This commit is contained in:
Agusti Fernandez Pardo
2022-07-08 20:19:51 +02:00
parent 530752147e
commit c8829fc08b
+3 -3
View File
@@ -2,7 +2,7 @@ import { NextMiddleware } from "next-api-middleware";
import z from "zod";
const withPage = z.object({
pageNumber: z
page: z
.string()
.min(1)
.default("1")
@@ -16,8 +16,8 @@ const withPage = z.object({
});
export const withPagination: NextMiddleware = async (req, _, next) => {
const { pageNumber, take } = withPage.parse(req.query);
const skip = pageNumber * take;
const { page, take } = withPage.parse(req.query);
const skip = page * take;
req.pagination = {
take: take || 10,
skip: skip || 0,