Fix: Mount v1Router to enable /api/v1/* routes#21
Conversation
There was a problem hiding this comment.
Good targeted fix — mounts v1Router at the canonical /api/v1 namespace and wraps the legacy /api routes with a deprecation middleware. A few things worth discussing before merge:
Route ordering looks correct. Express matches in declaration order, so /api/v1/* hits v1Router before the broader /api prefix kicks in. No issue there.
The app.use('/', portfolioRouter) mount is a concern. This was pre-existing, but with this PR now explicitly formalizing the namespace strategy it's worth addressing: any route defined in portfolioRouter (e.g. /portfolio/:address) is now reachable at both /api/portfolio/:address and /portfolio/:address (root-level). That's likely unintentional exposure and should be removed or documented.
v1Router contents aren't visible in this diff. The fix assumes v1Router already exists and is correct — but we can't verify whether it exposes the same contract as the documented /api/v1/* endpoints, or if it's a thin re-export of portfolioRouter. Worth a quick note confirming what's inside, especially since this is the canonical namespace going forward.
No test coverage added. Even a single integration test confirming GET /api/v1/portfolio/:address returns 200 and GET /api/portfolio/:address returns 200 with a deprecation header would lock this in and prevent future regressions.
The core change is minimal and the intent is sound. Clean up the root mount concern and we're good.
It's done. Added integration tests - Tests verify:
|
|
Thanks I will review shortly |
- Import and mount v1Router at /api/v1 (canonical namespace) - Add legacyApiDeprecation middleware to /api routes - Fixes 404 errors on all /api/v1/* endpoints Closes grantFoxin#9
- Remove app.use('/', portfolioRouter) to prevent unintentional root-level exposure
- Add integration tests for /api/v1/* (canonical) and /api/* (legacy)
- Tests verify both namespaces work and deprecation headers are present
ba5d74c to
cc75786
Compare
|
nice job |
Closes #9
Changes
v1Routerat/api/v1(canonical namespace)legacyApiDeprecationmiddleware to/apiroutes (legacy namespace)Testing