-
Notifications
You must be signed in to change notification settings - Fork 0
Product route: No pagination on list endpoint #17
Copy link
Copy link
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Severity: Medium
Category: Performance
Description
In api/src/routes/product.ts, the GET / endpoint returns the full product array on every call with no pagination support. As the dataset grows, this becomes increasingly expensive to serialize and transfer.
Suggested Fix
Support ?page=1&limit=20 query parameters with sensible defaults:
router.get('/', (req, res) => {
const page = parseInt(req.query.page as string, 10) || 1;
const limit = parseInt(req.query.limit as string, 10) || 20;
const start = (page - 1) * limit;
const paginatedProducts = products.slice(start, start + limit);
res.json({
data: paginatedProducts,
total: products.length,
page,
limit,
});
});Note: this would be a breaking change for the frontend, which currently expects a bare array response.
Affected File
api/src/routes/product.ts(GET / handler, lines 108-110)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request