Pages every list route the same way. It reads the page a list route's query string asks for, and cuts the rows a service fetched into that page, which the routes send as PaginatedData.

Functions

f
pageOf<T>(
rows: T[],
limit: number
): Page<T>

Turns rows fetched with LIMIT limit + 1 into a page. The extra row, when it comes back, is dropped and tells that another page follows, which spares a COUNT(*) over the whole list.

f
parsePagination(
params: URLSearchParams,
defaultLimit?
): { page: number; limit: number; }

Reads the page and limit query parameters of a list route. It never fails: a missing or invalid page reads as 1, and limit is kept between 1 and PAGINATION_MAX_LIMIT.

Interfaces

I
Page

Returned to the routes by the services' list functions, and sent as PaginatedData.