Skip to content

Feat/api versioning v1#385

Open
sweetesty wants to merge 9 commits into
JosephOnuh:mainfrom
sweetesty:feat/api-versioning-v1
Open

Feat/api versioning v1#385
sweetesty wants to merge 9 commits into
JosephOnuh:mainfrom
sweetesty:feat/api-versioning-v1

Conversation

@sweetesty
Copy link
Copy Markdown
Contributor

Closes #260


This PR adds /api/v1/ versioning to all routes, resolves all compiler and IDE errors surfaced during migration, and validates the versioned routes with a full passing test suite.

Route versioning

  • All API routes moved under /api/v1/ prefix in the Next.js app/api/v1/ directory
  • Old unversioned routes return 301 Moved Permanently redirects to their /api/v1/ equivalents
  • All frontend API call URLs updated to /api/v1/ paths — no unversioned URLs remaining
  • README.md updated with API versioning strategy, current version, and redirect behaviour for legacy URLs

Compiler & IDE fixes resolved during migration

  1. Missing Dispute typesDispute interface and DisputeStatus type added to src/types/index.ts; was causing errors in admin components and services
  2. React Query implicit anyerr parameter in CircleChat.tsx mutation onError callback explicitly cast as Error
  3. Missing state in JoinCircleForm.tsxnoSavedKey / setNoSavedKey state declaration was absent; added via useState(false)
  4. Payout type resolutionPayoutHistoryRow interface extracted to @/types/index.ts to resolve compiler failures on dynamic route imports in PayoutHistory.tsx and the payouts route
  5. NextAuth session.user.id type errorssession.user safely cast as { id: string } | undefined across 5 route files (approve, reject, pending-requests, contribute/verify, leave). Note: this pattern repeating across routes is a candidate for consolidation into a next-auth.d.ts session type extension as a follow-up
  6. userId used before declaration in join/route.ts — latent runtime bug surfaced by the migration; fixed at the declaration site
  7. Zod validation in testscircle-1 test string replaced with a valid UUID; Stellar public key and HTTPS horizonUrl mocked to satisfy SDK validation
  8. CreateCircleForm test isolation — replaced fragile mockResolvedValueOnce with a mockImplementation that cleanly intercepts background FX rate queries on mount, preventing mock assertion interference on form submissions

Test suite — 4/4 suites passing

  • src/app/api/v1/circles/[id]/join/__tests__/route.test.ts
  • src/app/api/v1/circles/[id]/contribute/__tests__/route.test.ts
  • src/app/api/v1/circles/[id]/contribute/verify/__tests__/route.test.ts
  • src/components/circle/__tests__/CreateCircleForm.test.tsx

Acceptance criteria met:

  • ✅ All routes moved under /api/v1/
  • ✅ Old routes return 301 redirect to versioned routes
  • ✅ API version documented in README
  • ✅ Frontend updated to use versioned URLs

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented May 29, 2026

@sweetesty Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@JosephOnuh
Copy link
Copy Markdown
Owner

resolve conflicts please

sweetesty added 8 commits May 29, 2026 11:40
…e state, waitlist notification, circleTemplates fields, test fixtures
…cessDueCycles, versioned circle/contribute routes, profile page trustline reset, package.json bullmq/ioredis fix
…polyfills, Jest node environments, flexible SQL string matchers, mock resets, and global ioredis/bullmq mocks
…reputation route migration, and Jest JSDOM edge primitives polyfills
@sweetesty
Copy link
Copy Markdown
Contributor Author

@JosephOnuh done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add API versioning (/api/v1/) to all routes

2 participants