0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-30 04:32:38 +00:00

pagesize as input

This commit is contained in:
Víctor Losada Hernández
2024-02-15 08:48:47 +01:00
parent ea1855485c
commit 153ab63393
3 changed files with 74 additions and 34 deletions

View File

@@ -8,9 +8,10 @@ const archive = {
findBrews : async (req, res, next)=>{
try {
const title = req.query.title || '';
const page = parseInt(req.query.page) || 1;
const page = Math.max(parseInt(req.query.page) || 1, 1);
console.log('trying page ', page);
const pageSize = 10; // Set a default page size
const minPageSize = 6;
const pageSize = Math.max(parseInt(req.query.size) || 10, minPageSize);
const skip = (page - 1) * pageSize;
const titleQuery = {