feat(api): GET /projects list endpoint#229
Conversation
The web UI demo's project switcher needs to enumerate projects; listProjects() exists in the DB layer (backs the MCP list_projects tool) but had no REST endpoint — GET /projects 404'd. Second of the roadmap-first reads unblocking the demo (after #226). - GET /projects → ProjectListItem[] ({id, name}, ordered by name), reusing listProjects(pool). - openapi.yaml adds the get: op on /projects + ProjectListItem schema; contract gate response-covers it. Closes #228 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds a ChangesGET /projects list endpoint
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/api/projects.integration.test.ts (1)
210-226: ⚡ Quick winPin the documented name-order guarantee in this integration test.
This test currently checks shape and membership, but not the “ordered by name” behavior the endpoint promises. Add an assertion that
body.datais nondecreasing byname(andidas tie-breaker if you want to mirror DB ordering).Suggested test assertion
expect(Array.isArray(body.data)).toBe(true); + const sorted = [...body.data].sort((a, b) => { + const byName = a.name.localeCompare(b.name); + return byName !== 0 ? byName : a.id.localeCompare(b.id); + }); + expect(body.data).toEqual(sorted); + const mine = body.data.find((p) => p.id === testProjectId);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/projects.integration.test.ts` around lines 210 - 226, The integration test for listing projects does not verify the documented ordering guarantee that results are sorted by name. After the existing loop that validates each project's structure (in the test function that checks 'returns 200 listing projects as {id, name}, including the test project'), add an assertion that validates body.data is sorted in non-decreasing order by the name field, optionally using id as a tie-breaker to match database ordering if needed. This ensures the test pins down the documented API contract about result ordering.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/api/projects.integration.test.ts`:
- Around line 210-226: The integration test for listing projects does not verify
the documented ordering guarantee that results are sorted by name. After the
existing loop that validates each project's structure (in the test function that
checks 'returns 200 listing projects as {id, name}, including the test
project'), add an assertion that validates body.data is sorted in non-decreasing
order by the name field, optionally using id as a tie-breaker to match database
ordering if needed. This ensures the test pins down the documented API contract
about result ordering.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: a876a28b-cad9-4ba0-8e24-23f1d4570765
📒 Files selected for processing (5)
openapi.yamlsrc/api/contract.integration.test.tssrc/api/projects.integration.test.tssrc/api/projects.tssrc/api/router.ts
Addresses CodeRabbit's nitpick that the ordering guarantee was untested. Asserts a controlled 'zzz-order-a'/'zzz-order-b' subset returns in name order rather than a full toEqual(sorted) over the whole table — the latter is flaky because it depends on the Postgres collation matching JS localeCompare and on no other suite's projects being present. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
CodeRabbit body nitpick addressed (no inline thread to resolve): pin the name-order guarantee in I implemented it deterministically rather than the suggested global |
With GET /libraries (#227) and GET /projects (#229) on main, the demo now bootstraps. This conforms the rest of it to main's actual API: - features.js capability map: panels check a flag and degrade to a clear "not available in this build" state instead of calling endpoints that 404. libraries/projectsList on (landed); library writes, project settings/sources, coordination/required-sections, and hard-delete stay off. - Repoint getSpecTree -> GET /specs/:id (the single-spec read already returns the tree). Drop the explicit deleteReference call — references are derived from paragraph text, so the paragraph PATCH re-derives them. - Restore the reference-web arcs by fetching project-scoped outbound references (GET /projects/:id/specs/:specId/references, ADR-024) per loaded spec. Verified end-to-end with Playwright: clean boot, default project auto-created, all bootstrap calls 200/201, zero console 404s, gated endpoints never hit. Closes #230 Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Why
The
examples/web_ui_demoproject switcher needs to enumerate projects.listProjects()exists in the DB layer (backs the MCPlist_projectstool) but had no REST endpoint —GET /projects404'd. Second of the roadmap-first reads unblocking the demo (after #226 / #227).What
GET /projects→ApiResponse<ProjectListItem[]>({id, name}, ordered by name), reusinglistProjects(pool).get:op to the existing/projects:openapi path + aProjectListItemschema; contract gate response-covers it.Testing
GET /projectslists{id, name}incl. the test project (added toprojects.integration.test.ts)pnpm lintclean (eslint + tsc + prettier)🤖 Co-authored by Claude Opus 4.8. Closes #228.
Summary by CodeRabbit
New Features
GET /projectsendpoint that returns a list of projects (including each project’s identifier and name) and orders them by project name.Tests
/projectsresponse, including contract/schema checks and deterministic name ordering.