parsePaginationParams
function parsePaginationParams(source, options?): PaginationInput;Defined in: pagination-params.ts:58
Parse untrusted transport params (query string, parsed body…) into a
PaginationInput, with sane defaults and clamping.
Style detection, in precedence order:
- cursor —
cursor,afterorbeforepresent (before⇒ backward) - offset —
offsetorskippresent (limit/takeset the size) - page —
pagepresent (page_size/pageSize/per_page/perPage/size) - otherwise the
fallbackstyle with defaults
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
source |
PaginationParamsSource |
options? |
ParsePaginationParamsOptions |
Returns
Section titled “Returns”Example
Section titled “Example”parsePaginationParams(new URL(req.url).searchParams);// ?page=3&per_page=25 → { type: "page", page: 3, pageSize: 25 }// ?limit=10&offset=40 → { type: "offset", limit: 10, offset: 40 }// ?cursor=abc&direction=backward → { type: "cursor", limit: 20, cursor: "abc", direction: "backward" }