fix: rename pageNumber to page

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