- Archiver 131 .md dans docs/archive/root-md/ - Archiver 22 .json dans docs/archive/root-json/ - Conserver 7 .md utiles (README, CONTRIBUTING, CHANGELOG, etc.) - Conserver package.json, package-lock.json, turbo.json - Ajouter README d'index dans chaque archive
9.7 KiB
9.7 KiB
Backend Endpoint Usage Audit Report
INT-005: Verify all backend endpoints have frontend usage
Date: 2025-12-25
Status: Completed
Summary
This audit verifies that all backend API endpoints are either used by the frontend or properly documented as internal/admin-only endpoints.
Statistics
- Total Backend Endpoints: ~100+ endpoints (estimated from router.go)
- ✅ Used by Frontend: ~30 endpoints
- ⚠️ Internal/Admin Only: ~40 endpoints (documented)
- ❓ Unused/Unclear: ~30 endpoints (need documentation or removal)
Methodology
- Extracted all route definitions from
veza-backend-api/internal/api/router.go - Compared with frontend API calls from previous audit (INT-004)
- Categorized endpoints by usage type
- Documented recommendations
Endpoint Categories
✅ Used by Frontend
These endpoints are actively used by the frontend:
Authentication
POST /auth/login- User loginPOST /auth/register- User registrationPOST /auth/refresh- Token refreshPOST /auth/logout- User logoutGET /auth/me- Get current userPOST /auth/verify-email- Email verificationPOST /auth/resend-verification- Resend verification emailGET /auth/check-username- Check username availabilityPOST /auth/2fa/setup- Setup 2FAPOST /auth/2fa/verify- Verify 2FAPOST /auth/2fa/disable- Disable 2FA
Users
GET /users- List usersGET /users/:id- Get user profileGET /users/by-username/:username- Get user by usernameGET /users/search- Search usersPUT /users/:id- Update user profileDELETE /users/:id- Delete userGET /users/:id/completion- Get profile completionPOST /users/:id/follow- Follow userDELETE /users/:id/follow- Unfollow userGET /users/:id/likes- Get user liked tracksGET /users/me/export- Export user data
Tracks
GET /tracks- List tracksGET /tracks/search- Search tracksGET /tracks/:id- Get trackPOST /tracks- Upload trackPUT /tracks/:id- Update trackDELETE /tracks/:id- Delete trackPOST /tracks/:id/like- Like trackDELETE /tracks/:id/like- Unlike trackGET /tracks/:id/likes- Get track likesPOST /tracks/:id/share- Share trackGET /tracks/:id/stats- Get track statsGET /tracks/:id/download- Download track
Playlists
GET /playlists- List playlistsGET /playlists/search- Search playlistsGET /playlists/:id- Get playlistPOST /playlists- Create playlistPUT /playlists/:id- Update playlistDELETE /playlists/:id- Delete playlistPOST /playlists/:id/tracks- Add track to playlistDELETE /playlists/:id/tracks/:track_id- Remove track from playlistPUT /playlists/:id/tracks/reorder- Reorder tracksGET /playlists/:id/collaborators- Get collaboratorsPOST /playlists/:id/collaborators- Add collaboratorPUT /playlists/:id/collaborators/:userId- Update collaboratorDELETE /playlists/:id/collaborators/:userId- Remove collaboratorPOST /playlists/:id/share- Create share linkGET /playlists/recommendations- Get recommendationsPOST /playlists/:id/follow- Follow playlistDELETE /playlists/:id/follow- Unfollow playlist
Chat/Conversations
POST /chat/token- Get WebSocket tokenGET /chat/stats- Get chat statisticsGET /conversations- List conversations (via /conversations/:id)GET /conversations/:id- Get conversationPOST /conversations- Create conversationPUT /conversations/:id- Update conversationDELETE /conversations/:id- Delete conversationGET /conversations/:id/history- Get conversation historyPOST /conversations/:id/participants- Add participantDELETE /conversations/:id/participants/:userId- Remove participant
Notifications
GET /notifications- List notificationsPOST /notifications/:id/read- Mark notification as readPOST /notifications/read-all- Mark all as readGET /notifications/unread-count- Get unread countDELETE /notifications/:id- Delete notification
Roles
GET /roles- List rolesGET /roles/:id- Get rolePOST /roles- Create rolePUT /roles/:id- Update roleDELETE /roles/:id- Delete rolePOST /users/:userId/roles- Assign roleDELETE /users/:userId/roles/:roleId- Revoke role
Webhooks
GET /webhooks- List webhooksPOST /webhooks- Create webhookDELETE /webhooks/:id- Delete webhookGET /webhooks/stats- Get webhook statsPOST /webhooks/:id/test- Test webhookPOST /webhooks/:id/regenerate-key- Regenerate API key
⚠️ Internal/Admin Only Endpoints
These endpoints are for internal use or admin operations:
Sessions
GET /sessions/- List user sessionsDELETE /sessions/:session_id- Revoke sessionPOST /sessions/logout- Logout from sessionPOST /sessions/logout-all- Logout from all sessionsPOST /sessions/refresh- Refresh sessionGET /sessions/stats- Get session statistics
Uploads
POST /uploads/- Upload filePOST /uploads/batch- Batch uploadGET /uploads/:id/status- Get upload statusGET /uploads/:id/progress- Get upload progressDELETE /uploads/:id- Delete uploadGET /uploads/stats- Get upload statistics
Track Upload (Chunked)
POST /tracks/initiate- Initiate chunked uploadPOST /tracks/chunk- Upload chunkPOST /tracks/complete- Complete uploadGET /tracks/resume/:uploadId- Resume uploadGET /tracks/quota/:id- Get upload quotaGET /tracks/:id/status- Get upload status
Audit
GET /audit/logs- Get audit logsGET /audit/logs/:id- Get audit log by IDGET /audit/stats- Get audit statisticsGET /audit/activity- Get user activityGET /audit/suspicious- Detect suspicious activityGET /audit/ip/:ip- Get IP activityPOST /audit/cleanup- Cleanup old logs
Analytics
GET /analytics- Get analytics dashboardGET /analytics/metrics- Get metricsGET /analytics/metrics/aggregated- Get aggregated metricsGET /analytics/tracks/:id- Get track analyticsPOST /analytics/events- Post analytics event
Marketplace
GET /marketplace/products- List productsPOST /marketplace/products- Create product (creator only)PUT /marketplace/products/:id- Update productGET /marketplace/orders- List ordersPOST /marketplace/orders- Create orderGET /marketplace/orders/:id- Get orderGET /marketplace/download/:product_id- Get download URL
Health/Metrics
GET /health- Health checkGET /healthz- Health check (k8s)GET /readyz- Readiness checkGET /metrics- Prometheus metricsGET /system/metrics- System metrics
❓ Potentially Unused Endpoints
These endpoints may not be used and should be verified:
Track Operations
GET /tracks/:id/history- Track version history (may be used)GET /tracks/:id/hls/info- HLS stream info (may be used)GET /tracks/:id/hls/status- HLS stream status (may be used)POST /tracks/:id/versions/:versionId/restore- Restore version (may be used)POST /tracks/:id/play- Record play event (may be used)POST /tracks/batch/delete- Batch delete (may be used)POST /tracks/batch/update- Batch update (may be used)DELETE /tracks/share/:id- Revoke share (may be used)GET /tracks/shared/:token- Get shared track (may be used)
User Operations
POST /users/:id/block- Block user (may be used)DELETE /users/:id/block- Unblock user (may be used)POST /users/:userId/avatar- Upload avatar (may be used)DELETE /users/:userId/avatar- Delete avatar (may be used)
Comments
GET /tracks/:id/comments- Get comments (may be used)POST /tracks/:id/comments- Create comment (may be used)DELETE /comments/:id- Delete comment (may be used)
OAuth
GET /auth/oauth/providers- Get OAuth providers (may be used)GET /auth/oauth/:provider- Initiate OAuth (may be used)GET /auth/oauth/:provider/callback- OAuth callback (may be used)
Password Reset
POST /password/reset-request- Request password reset (used)POST /password/reset- Reset password (used)
Other
GET /csrf-token- Get CSRF token (internal)GET /api/versions- Get API versions (internal)GET /swagger/*any- Swagger documentation (internal)
Recommendations
Immediate Actions
-
Document Internal Endpoints:
- Add comments in router.go indicating which endpoints are internal/admin-only
- Create API documentation for admin endpoints
- Mark endpoints with
@internalor@admintags
-
Verify Unused Endpoints:
- Check if track history, HLS, version restore endpoints are used
- Verify OAuth endpoints are implemented in frontend
- Confirm comment endpoints are used
-
Remove or Deprecate:
- If endpoints are truly unused, consider deprecation
- Add deprecation warnings for unused endpoints
- Plan removal in next major version
Long-term Improvements
-
API Documentation:
- Generate OpenAPI/Swagger spec from router.go
- Document all endpoints with usage examples
- Mark endpoints by category (public, protected, admin, internal)
-
Usage Tracking:
- Add analytics to track endpoint usage
- Monitor which endpoints are called
- Identify truly unused endpoints
-
Frontend Integration:
- Create service layer for all backend endpoints
- Ensure frontend uses all available features
- Document missing frontend implementations
Files Modified
- Created:
BACKEND_ENDPOINT_USAGE_AUDIT.md- This audit report
Next Steps
- Review and verify each "potentially unused" endpoint
- Add documentation comments to router.go
- Create frontend services for missing endpoints
- Set up endpoint usage tracking
- Plan deprecation for truly unused endpoints