[PR #2396] [MERGED] fix(api): add take parameter to template search query for pagination #2272

Closed
opened 2026-02-26 20:33:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/documenso/documenso/pull/2396
Author: @jormigo
Created: 1/17/2026
Status: Merged
Merged: 1/27/2026
Merged by: @Mythie

Base: mainHead: fix/template-pagination-ignores-per-page


📝 Commits (1)

  • 0e3dd78 fix(api): add take parameter to template search query for pagination

📊 Changes

1 file changed (+1 additions, -0 deletions)

View changed files

📝 packages/lib/server-only/template/find-templates.ts (+1 -0)

📄 Description

Description

This PR fixes a bug in the /api/v2/template endpoint where the pagination parameter perPage was being ignored. Previously, the endpoint would return all matching templates regardless of the requested limit, which could lead to performance issues and incorrect API behavior.

Fixes #2395

Changes Made

Testing Performed

I have verified the changes manually using curl against a local instance:

  • Before Fix: Requesting perPage=1 returned all 2 templates in the database.
  • After Fix: Requesting perPage=1 returns exactly 1 template as expected.
  • Verified that page=2 correctly returns the subsequent results.
  • Validated that existing pagination for /api/v2/envelope and /api/v2/document remains unaffected.

Checklist

  • I have tested these changes locally and they work as expected.
  • I have added/updated tests that prove the effectiveness of these changes.
  • I have updated the documentation to reflect these changes, if applicable.
  • I have followed the project's coding style guidelines.
  • I have addressed the code review feedback from the previous submission, if applicable.

Additional Notes

The response metadata (perPage, totalPages, etc.) was already correct, but the data array contained more items than it should have. This change aligns the data length with the metadata.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/documenso/documenso/pull/2396 **Author:** [@jormigo](https://github.com/jormigo) **Created:** 1/17/2026 **Status:** ✅ Merged **Merged:** 1/27/2026 **Merged by:** [@Mythie](https://github.com/Mythie) **Base:** `main` ← **Head:** `fix/template-pagination-ignores-per-page` --- ### 📝 Commits (1) - [`0e3dd78`](https://github.com/documenso/documenso/commit/0e3dd78340336a05db02cd11e1c7ec3c0d4a5f64) fix(api): add take parameter to template search query for pagination ### 📊 Changes **1 file changed** (+1 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `packages/lib/server-only/template/find-templates.ts` (+1 -0) </details> ### 📄 Description ## Description This PR fixes a bug in the `/api/v2/template` endpoint where the pagination parameter `perPage` was being ignored. Previously, the endpoint would return all matching templates regardless of the requested limit, which could lead to performance issues and incorrect API behavior. ## Related Issue Fixes #2395 ## Changes Made - Updated [packages/lib/server-only/template/find-templates.ts](cci:7://file:///Users/jorge/dev/documenso/packages/lib/server-only/template/find-templates.ts:0:0-0:0) to include `take: perPage` in the `prisma.envelope.findMany` call. This ensures the database query respects the requested page size. ## Testing Performed I have verified the changes manually using `curl` against a local instance: - **Before Fix**: Requesting `perPage=1` returned all 2 templates in the database. - **After Fix**: Requesting `perPage=1` returns exactly 1 template as expected. - Verified that `page=2` correctly returns the subsequent results. - Validated that existing pagination for `/api/v2/envelope` and `/api/v2/document` remains unaffected. ## Checklist - [x] I have tested these changes locally and they work as expected. - [ ] I have added/updated tests that prove the effectiveness of these changes. - [ ] I have updated the documentation to reflect these changes, if applicable. - [x] I have followed the project's coding style guidelines. - [ ] I have addressed the code review feedback from the previous submission, if applicable. ## Additional Notes The response metadata (`perPage`, `totalPages`, etc.) was already correct, but the `data` array contained more items than it should have. This change aligns the `data` length with the metadata. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-26 20:33:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/documenso#2272
No description provided.