Skip to content

SudoSOS Back-end API / helpers / toResponse

Function: toResponse() ​

ts
function toResponse<R>(
   records, 
   count, 
   pagination): object;

Build a paginated response from a [records, count] tuple. Use this in controllers to wrap service results into the standard paginated response format.

Type Parameters ​

Type Parameter
R

Parameters ​

ParameterTypeDescription
recordsR[]The records to include in the response
countnumberThe total number of matching records (before pagination)
paginationPaginationParametersThe pagination parameters used for the query

Returns ​

object

_pagination ​

ts
_pagination: PaginationResult;

records ​

ts
records: R[];