-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Description
Priority
🟡 Minor - API Design & Maintainability
Locations
src/app/(payload)/api/[...slug]/route.tssrc/app/(frontend)/api/auth/[...all]/route.ts- All custom API routes
Problem Description
API routes lack versioning, making future breaking changes difficult.
Issues
1. Breaking Changes Break Clients
Cannot make breaking changes without breaking existing clients.
2. No Backward Compatibility
Cannot maintain multiple API versions.
3. No Migration Path
Clients don't know when API changes, no deprecation warnings.
4. Testing Challenges
Cannot test old vs new API versions.
Expected Behavior
Option 1: URL Path Versioning (Recommended)
/api/v1/lessons/:id
/api/v2/lessons/:id
Create directory structure for v1, v2, etc.
Recommendation: URL Path Versioning
Directory Structure
src/app/api/
├── v1/
│ ├── compile/
│ ├── lessons/
│ └── progress/
├── v2/
│ └── ...
└── route.ts ← Redirect /api to /api/v1
Migration Strategy
Phase 1: Add v1 Structure (Non-breaking)
Move existing routes to /api/v1/, add redirect from /api to /api/v1
Phase 2: Add v2 (Non-breaking)
Create /api/v2/ with new implementation
Phase 3: Deprecation Warning
Add deprecation header to v1
Phase 4: Remove v1
After sunset date, remove v1
Related Issues
- Minor: Empty Package Name in package.json #19 - No API documentation
- #033 - TypeScript not strict enough
Steps to Fix
- Create
/api/v1/directory structure - Move existing routes to v1
- Add redirect from
/apito/api/v1 - Document API versioning in API.md
- Add version header to all responses
- Plan for v2 when breaking changes needed
Additional Context
This may seem premature for a new project, but establishing versioning early prevents pain later. The project already has multiple API consumers (web app, potentially mobile apps, etc.) and breaking changes will be needed.
Reactions are currently unavailable