Judicial Backend’s search and statistics endpoints return potentially large result sets. To keep response sizes predictable, every listing endpoint that can return multiple records acceptsDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt
Use this file to discover all available pages before exploring further.
page and limit query parameters and embeds pagination metadata directly in the response envelope. The logic is centralized in a small utility (parsePaginacion) and two shared TypeScript interfaces so every controller applies the same defaults and computes offsets consistently.
Type Definitions
Two interfaces live insrc/core/types/pagination.types.ts:
PaginationQuery mirrors req.query — Express query string values are always string (or string[]), so both fields are typed as string | undefined. Paginacion holds the parsed, numeric values returned by the utility function.
The
Paginacion interface does not include a skip field. Instead, services compute skip inline as (page - 1) * limit when slicing result arrays or building TypeORM queries.parsePaginacion Utility
- Parses
query.pageandquery.limitwithNumber()— values that areundefined, empty strings, or non-numeric becomeNaN, which the||fallback converts to the default. - Clamps both values to a minimum of
1withMath.max(1, ...)so negative or zero values are silently corrected. - Returns the
Paginacionobject; callers computeskipthemselves as(page - 1) * limit.
Default values
| Parameter | Default | Minimum |
|---|---|---|
page | 1 | 1 |
limit | 10 | 1 |
Query Parameters
The 1-indexed page number to retrieve. Values below
1 are clamped to 1. Non-numeric values fall back to the default.The maximum number of records to return per page. Values below
1 are clamped to 1. Non-numeric values fall back to 10.How Controllers Use parsePaginacion
Controllers destructure the result and pass page and limit directly to the service:
How Services Apply Pagination
Services receivepage and limit as plain numbers and apply the offset calculation themselves:
Paginated Response Shape
Services return pagination metadata alongside the data array. The controller wraps this in the standardresponseUtil.success envelope:
data object by each service are:
| Field | Type | Description |
|---|---|---|
total | number | Total number of records matching the applied filters. |
page | number | The current page number as received (or defaulted). |
limit | number | The page size as received (or defaulted). |
apelaciones / planos / historicos | array | The sliced result set for the requested page. |
Math.ceil(total / limit).
Endpoints That Support Pagination
| Method | Path | Service |
|---|---|---|
GET | /api/busquedas | BusquedaApelacionService.getApelaciones |
GET | /api/busquedas/plano | BusquedaPlanoService.getPlanos |
GET | /api/busquedas/historico | BusquedaHistoricoService.getHistoricos |
GET | /api/estadisticas/plano | EstadisticaService.getReportePlano |
400 Bad Request before pagination is applied.