API: Add GET /api/comparisons endpoint for public feed #1
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
The Explore page currently uses hardcoded mock data. We need a REST endpoint that returns paginated public comparisons from the database.
Backend
The server action
getPublicComparisons()already exists insrc/app/actions/comparison.ts(line 102-114). Create a proper API route that:Create
src/app/api/comparisons/route.tsGET /api/comparisons?page=1&limit=20&search=&category=comparisonstable whereisPublic=true AND status='completed'searchquery param (ILIKE on title)categoryfilter (tags array overlap)comparisonItemsto include item names in responsetotalCountfor paginationCreate
src/app/api/comparisons/[slug]/route.tsGET /api/comparisons/:slug— already partially called by results pageviewCounton each GETComparisonDatashapeResponse Shape
Files
src/app/api/comparisons/route.tssrc/app/api/comparisons/[slug]/route.tssrc/app/actions/comparison.ts(existing queries to reuse)src/lib/db/schema.ts(table schemas)Acceptance Criteria