feat(api): add pagination and metadata to invoice listing#62
Merged
mikewheeleer merged 4 commits intoLiquifact:mainfrom Apr 1, 2026
Merged
Conversation
|
@chibokaxavier Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
Contributor
|
resolve the conflicts |
Contributor
Author
|
@mikewheeleer kindly review all |
Contributor
|
Please resolve the conflicts |
Contributor
|
@chibokaxavier Resolve the conflicts |
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.
Fixes #9
📝 Executive Summary
This PR implements Offset-based Pagination for the
GET /api/invoicesendpoint. By allowing clients to specifypageandlimitparameters, we significantly reduce payload sizes, improve database performance, and provide a scalable way to handle large datasets.🛠 Key Technical Enhancements
1. Smart Pagination Logic
Dynamic Querying: Added support for
pageandlimitparameters with automatic defaults (Page 1, Limit 10).Input Sanitization: Implemented strict parsing to handle edge cases—negative numbers default to
1, and limits are capped at100to prevent "mega-queries."Decoupled Architecture: Refactored the app entry point to enable seamless Supertest integration, ensuring high reliability for future API changes.
2. Rich Metadata Response
The response now includes a robust
metaobject to assist frontend navigation:⚡ Pagination Response Example
📂 Core File Impact
File | Change Type | Description -- | -- | -- invoiceRoutes.js | Update | Integrated query parameter parsing for the GET collection. invoiceService.js | Logic | Implemented slice/offset logic for data retrieval. app.js | Refactor | Enhanced for better test environment compatibility. pagination.test.js | Quality | 14 new tests covering edge cases and bounds.🧪 Testing & Quality Assurance
Verified the implementation with a comprehensive test suite covering malformed inputs and out-of-bounds requests.
🔐 Security & Integrity
Input Boundary Protection: All query parameters are strictly cast to integers with floor/ceiling boundaries to prevent injection or server strain.
Error Masking: Service-level failures are caught and returned as sanitized
500errors in production.✅ Final Checklist
Performance: Verified that pagination reduces response time for large sets.
Testing: 14 unit and integration tests passing.
Documentation: Updated API docs in README.md.
CI/CD: Branch is green and ready for merge.