From 0e084de1c5fce99e0d16e29bf4dda6f9261c2a7c Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Tue, 16 Dec 2025 11:31:18 +1000 Subject: [PATCH] feat: increase tools API limit to 1000 and optimize response payload - Increase max limit from 50 to 1000 for bulk tool fetching - Exclude large fields (npmReadme, npmAuthor, npmMaintainers) from API response - Reduces payload size while maintaining all necessary tool metadata --- apps/web/src/app/api/tools/route.ts | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/apps/web/src/app/api/tools/route.ts b/apps/web/src/app/api/tools/route.ts index 4e8d31b..464a21d 100644 --- a/apps/web/src/app/api/tools/route.ts +++ b/apps/web/src/app/api/tools/route.ts @@ -96,7 +96,7 @@ function buildWhereClause( * - importHealth: Filter by import health (HEALTHY, BROKEN, UNKNOWN) * - executionHealth: Filter by execution health (HEALTHY, BROKEN, UNKNOWN) * - broken: Shorthand for "at least one health check failed" (true/false) - * - limit: Results per page (default: 20, max: 50) + * - limit: Results per page (default: 20, max: 1000) * - offset: Pagination offset (default: 0) */ export async function GET(request: NextRequest) { @@ -119,8 +119,8 @@ export async function GET(request: NextRequest) { const limitParam = searchParams.get('limit'); const offsetParam = searchParams.get('offset'); - // Validate and set defaults - const limit = Math.min(Number.parseInt(limitParam || '20', 10), 50); + // Validate and set defaults - max limit of 1000 for bulk fetching + const limit = Math.min(Number.parseInt(limitParam || '20', 10), 1000); const offset = Math.max(Number.parseInt(offsetParam || '0', 10), 0); // Build filters @@ -133,7 +133,26 @@ export async function GET(request: NextRequest) { const tools = await prisma.tool.findMany({ where, include: { - package: true, // Include package data for each tool + package: { + select: { + id: true, + npmPackageName: true, + npmVersion: true, + npmDescription: true, + npmRepository: true, + npmHomepage: true, + npmLicense: true, + npmKeywords: true, + category: true, + env: true, + frameworks: true, + tier: true, + isOfficial: true, + npmDownloadsLastMonth: true, + githubStars: true, + // Explicitly exclude npmReadme, npmAuthor, npmMaintainers to reduce payload + }, + }, }, orderBy: [ { qualityScore: 'desc' }, // Tool quality score