detectBadPaginationMiddleware

Source
import { detectBadPaginationMiddleware } from "@prestojs/rest";
detectBadPaginationMiddleware(isPaginated)

Middleware that detects if paginationMiddleware isn't present when it should be or if pagination option to Endpoint.execute hasn't been supplied.

This helps avoid cryptic errors when a response is paginated but other middleware expects to receive just the results (eg. viewModelCachingMiddleware).

It is recommended you add this to the global list of middleware:

Endpoint.defaultConfig.middleware = [
...Endpoint.defaultConfig.middleware,
detectBadPaginationMiddleware(),
];
ParameterTypeDescription
*isPaginated
Function

Function that returns true if a response is paginated. By default this uses InferredPaginator.getPaginationState to determine this. If you use custom pagination class(es) you should provide this function.

DetectBadPaginationMiddleware