Build a Next.js API route that lets developers search and filter the climate tech project database. `GET /api/climate-projects?q=&category=&language=&minStars=&needsContributors=&limit=20&cursor=` Database table `climate_projects`: ```sql id uuid PK, name text, description text, repo_url text, category text, primary_language text, stars integer, has_good_first_issues boolean, last_commit_at timestamptz, created_at timestamptz ``` Query behavior: 1. Full-text search on `name` and `description` using PostgreSQL `to_tsvector('english', name || ' ' || description)` — add a GIN index 2. Filter by `category` (exact match), `primary_language` (exact match), `minStars` (>=), `needsContributors` (maps to `has_good_first_issues = true`) 3. Sort: by text rank if `q` is provided, otherwise `stars DESC` 4. Cursor-based pagination: `cursor` is an opaque base64-encoded `{id, stars}` pair 5. Response: `{ projects: Project[], total: number, nextCursor: string | null }` Validate all query params with zod. Return 400 with descriptive error on invalid params. Include the Drizzle migration for the `climate_projects` table with proper indexes.
No contributions yet.