@clipboard-health/json-api-nestjs
Version:
TypeScript-friendly utilities for adhering to the JSON:API specification with NestJS.
15 lines (14 loc) • 822 B
TypeScript
/**
* NestJS-specific query processing based on the output of `ctx.switchToHttp().getRequest().query`.
*
* We handle the following cases:
* 1. For `?filter[age]=10,20`, `value` is `10,20`, which we transform to `{eq: "10,20"}`.
* 2. For `?filter[age]=20`, `value` is `20`, which we transform to `{eq: "20"}`.
* 3. For `?filter[age][gt]=10&filter[age]=20`, `value` is `{'20': true, gt: '10'}`, which we
* transform to `{eq: "20", gt: "10"}`.
* 4. For `?filter[age]=10&filter[age]=20`, `value` is `['10', '20']`, which we transform to `{eq:
* "10,20"}`.
* 5. For `?filter[age][gt]=5&filter[age]=10&filter[age]=20`, `value` is `{'0': '10', '1': '20', gt:
* '5'}`, which we transform to `{eq: "10,20", gt: "5"}`.
*/
export declare function queryFilterPreprocessor(value: unknown): Record<string, string>;