Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
docs(search): publish the limit and offset bounds
Yudhi Armyndharis7224196deb79
diff --git a/src/modules/search/dto/search-query.dto.spec.ts b/src/modules/search/dto/search-query.dto.spec.tsindex cef8d3b2e..4c9f276f1 100644--- a/src/modules/search/dto/search-query.dto.spec.ts+++ b/src/modules/search/dto/search-query.dto.spec.ts@@ -1,6 +1,8 @@+import { DECORATORS } from '@nestjs/swagger';import { validateSync } from 'class-validator';import { plainToInstance } from 'class-transformer';import { SearchQueryDto } from './search-query.dto';+import { SEARCH_OFFSET_MAX } from '../search.constants';describe('SearchQueryDto', () => {// Mirrors how the global ValidationPipe (transform:true + enableImplicitConversion) instantiates@@ -68,4 +70,12 @@ describe('SearchQueryDto', () => {const dto = fromQuery({ q: 'hello' });expect(validateSync(dto)).toHaveLength(0);});++ // @nestjs/swagger derives no bounds from @IsInt/@Min/@Max, so the decorator has to state them.+ it('publishes limit and offset as bounded integers', () => {+ const published = (key: string): unknown =>+ Reflect.getMetadata(DECORATORS.API_MODEL_PROPERTIES, SearchQueryDto.prototype, key);+ expect(published('limit')).toMatchObject({ type: 'integer', minimum: 1 });+ expect(published('offset')).toMatchObject({ type: 'integer', minimum: 0, maximum: SEARCH_OFFSET_MAX });+ });});diff --git a/src/modules/search/dto/search-query.dto.ts b/src/modules/search/dto/search-query.dto.tsindex 0faae4253..960ec2a8a 100644--- a/src/modules/search/dto/search-query.dto.ts+++ b/src/modules/search/dto/search-query.dto.ts@@ -63,14 +63,19 @@ export class SearchQueryDto {@IsNumber()dateTo?: number;- @ApiPropertyOptional({ description: 'Max hits to return', type: Number })+ @ApiPropertyOptional({ description: 'Max hits to return', type: 'integer', minimum: 1 })@IsOptional()@Type(() => Number)@IsInt()@Min(1)limit?: number;- @ApiPropertyOptional({ description: `Pagination offset, at most ${SEARCH_OFFSET_MAX}`, type: Number })+ @ApiPropertyOptional({+ description: `Pagination offset, at most ${SEARCH_OFFSET_MAX}`,+ type: 'integer',+ minimum: 0,+ maximum: SEARCH_OFFSET_MAX,+ })@IsOptional()@ToStrictNumber()@Type(() => Number)