Skip to content

feat(vendors): add pagination and limit validation to GET/vendors#85

Open
GoluScriptMage wants to merge 2 commits into
StepFi-app:mainfrom
GoluScriptMage:feat-vendors-pagination
Open

feat(vendors): add pagination and limit validation to GET/vendors#85
GoluScriptMage wants to merge 2 commits into
StepFi-app:mainfrom
GoluScriptMage:feat-vendors-pagination

Conversation

@GoluScriptMage

Copy link
Copy Markdown

🔗 Related Issue

Closes #78                                                                  
                                                                            
---                                                                         
                                                                            
## 🔖 Title
feat(vendors): add pagination and limit validation to GET /vendors          

---

## 📝 Description
Adds query-based pagination (`page` and `limit`) to the `GET /vendors`      

endpoint. This prevents performance degradation when the table grows to
hundreds of vendors by replacing the full table scan with scoped database
ranges.

---

## 🔄 Changes Made
- [x] Created `VendorListQueryDto` to validate query parameters (default    

page=1, limit=20, max limit=100).
- [x] Created VendorListResponseDto to format responses with standard
pagination metadata.
- [x] Updated VendorsService.getAll to map ranges (.range(offset, offset + limit - 1)) and retrieve total count from Supabase.
- [x] Updated VendorsController.list to bind query decorators and generate
Swagger documentation.

---

## 📸 Screenshots (if applicable)
*N/A (Backend API changes only)*

---

## 🗒️ Additional Notes
- Verified backend compilation locally using `npm run build` (build         

completes with zero errors).

@GoluScriptMage GoluScriptMage requested a review from EmeditWeb as a code owner July 5, 2026 05:30
Copilot AI review requested due to automatic review settings July 5, 2026 05:30

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/limit query validation via VendorListQueryDto (default page=1, limit=20; max limit=100).
  • Updates VendorsService.getAll to fetch a scoped range and return total count using Supabase count: 'exact'.
  • Updates GET /vendors controller 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 thread src/modules/vendors/dto/vendor-list-query.dto.ts Outdated
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants