TuKit applies consistent pagination across all list endpoints using a sharedDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/tukit/llms.txt
Use this file to discover all available pages before exploring further.
Paginate middleware. Page number and results per page are embedded in the URL path rather than query string parameters — both are declared as optional route segments (:pag? and :perpage?), so they can be omitted entirely to fall back to defaults. The middleware translates those values into skippag and limit properties on req.body, which are then used by every controller to construct the underlying MongoDB query.
URL Pattern
All paginated endpoints embed the page number and results per page directly in the URL path. Here are the paginated routes currently defined across the user, product, and shopping-cart routers:All paginated endpoints use
POST, not GET. Authentication via the token-access header is required on most routes — check individual endpoint references for their specific middleware chain.Paginate Middleware
ThePaginate middleware reads :pag and :perpage from the URL params and writes the computed skippag and limit values onto req.body before the controller runs:
- If
pagis greater than1, the skip value is(pag - 1) * perpage. For example, page 3 with 10 results per page skips(3 - 1) * 10 = 20documents. - If
pagis1or absent,pagresolves to0, soskippag = 0 * perpage = 0— the query starts from the first document.
| Param | Default | Meaning |
|---|---|---|
:perpage | 10 | Returns up to 10 results per page |
:pag | 0 (resolves to skip 0) | Starts from the beginning of the result set |
req.body.skippag and req.body.limit directly in their MongoDB queries (e.g. .skip(skippag).limit(limit)).
Response Shape
Every paginated endpoint returns a consistent envelope that includes apagination object alongside the data array:
pag
The current page number as passed in the request URL.
perpage
The number of results per page as passed in the request URL (or
10 if omitted).pags
The total number of pages available, calculated as
Math.ceil(totalCount / perpage). Use this to drive “next page” logic in your client.pag against pags. When pag >= pags, you have reached the last page.
Examples
The examples below use thelist-my-buy endpoint, but the same pattern applies to every paginated route.
Page 1, 10 results per page (explicit):