feat(vendors): add pagination and limit validation to GET/vendors#85
Open
GoluScriptMage wants to merge 2 commits into
Open
feat(vendors): add pagination and limit validation to GET/vendors#85GoluScriptMage wants to merge 2 commits into
GoluScriptMage wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds query-parameter pagination to the GET /vendors endpoint to avoid returning the full vendors table as it grows, and standardizes the response to include pagination metadata (including total count).
Changes:
- Introduces
page/limitquery validation viaVendorListQueryDto(default page=1, limit=20; max limit=100). - Updates
VendorsService.getAllto fetch a scoped range and return total count using Supabasecount: 'exact'. - Updates
GET /vendorscontroller route and Swagger metadata to reflect the paginated response shape.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/modules/vendors/vendors.service.ts | Implements offset/limit paging via Supabase .range(...) and returns a paginated response envelope. |
| src/modules/vendors/vendors.controller.ts | Binds query DTO for pagination inputs and updates Swagger response contract. |
| src/modules/vendors/dto/vendor-list-response.dto.ts | Adds a paginated list response DTO (data + pagination meta + message). |
| src/modules/vendors/dto/vendor-list-query.dto.ts | Adds validation/transforms for type, page, and limit query parameters. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
70
to
73
| if (error) { | ||
| this.logger.error(`Failed to list vendors: ${error.message}`); | ||
| throw new Error('Failed to list vendors.'); | ||
| } |
| minimum: 1, | ||
| }) | ||
| @IsOptional() | ||
| @Transform(({ value }) => parseInt(value, 10)) |
Comment on lines
+52
to
58
| async getAll( | ||
| page: number = 1, | ||
| limit: number = 20, | ||
| type?: VendorType, | ||
| ): Promise<VendorListResponseDto> { | ||
| const offset = (page - 1) * limit; | ||
| const client = this.supabaseService.getClient(); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔗 Related Issue
endpoint. This prevents performance degradation when the table grows to
hundreds of vendors by replacing the full table scan with scoped database
ranges.
page=1, limit=20, max limit=100).
- [x] Created
VendorListResponseDtoto format responses with standardpagination metadata.
- [x] Updated
VendorsService.getAllto map ranges (.range(offset, offset + limit - 1)) and retrieve total count from Supabase.- [x] Updated
VendorsController.listto bind query decorators and generateSwagger documentation.
completes with zero errors).