Implement URI-based API versioning with /api/v1 prefix across all routes.
This establishes a foundation for future API evolution and breaking changes.
Changes:
- server.ts: All routes mounted under /api/v1/ (15 route handlers)
- apiClient.ts: Base URL updated to /api/v1
- swagger.ts: OpenAPI server URL changed to /api/v1
- Redirect middleware: Added backwards compatibility for /api/* → /api/v1/*
- Tests: Updated 72 test files with versioned path assertions
- ADR documentation: Marked Phase 1 as complete (Accepted status)
Test fixes:
- apiClient.test.ts: 27 tests updated for /api/v1 paths
- user.routes.ts: 36 log messages updated to reflect versioned paths
- swagger.test.ts: 1 test updated for new server URL
- All integration/E2E tests updated for versioned endpoints
All Phase 1 acceptance criteria met:
✓ Routes use /api/v1/ prefix
✓ Frontend requests /api/v1/
✓ OpenAPI docs reflect /api/v1/
✓ Backwards compatibility via redirect middleware
✓ Tests pass with versioned paths
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Updated tests in `useShoppingLists`, `useWatchedItems`, and various components to use `waitFor` for asynchronous assertions.
- Enhanced error handling in `errorHandler` middleware tests to include validation errors and status codes.
- Modified `AuthView`, `ProfileManager.Auth`, and `ProfileManager.Authenticated` tests to check for `AbortSignal` in API calls.
- Removed duplicate assertions in `auth.routes.test`, `budget.routes.test`, and `gamification.routes.test`.
- Introduced reusable logger matcher in `budget.routes.test`, `deals.routes.test`, `flyer.routes.test`, and `user.routes.test`.
- Simplified API client mock in `aiApiClient.test` to handle token overrides correctly.
- Removed unused `apiUtils.ts` file.
- Added `ApiContext` and `ApiProvider` for better API client management in React components.
- Added a new DealsRepository class to interact with the database for fetching the best sale prices of watched items.
- Created a new route `/api/users/deals/best-watched-prices` to handle requests for the best prices of items the authenticated user is watching.
- Enhanced logging in the FlyerDataTransformer and FlyerProcessingService for better traceability.
- Updated tests to ensure proper logging and functionality in the FlyerProcessingService.
- Refactored logger client to support structured logging for better consistency across the application.
- Updated the Nominatim geocoding service to use a class-based structure and accept a logger instance for better logging control.
- Modified tests for the Nominatim service to align with the new structure and improved logging assertions.
- Removed the disabled notification service test file.
- Added a new GeocodingFailedError class to handle geocoding failures more explicitly.
- Enhanced error logging in the queue service to include structured error objects.
- Updated user service to accept a logger instance for better logging in address upsert operations.
- Added request-scoped logger to Express Request interface for type-safe logging in route handlers.
- Improved logging in utility functions for better debugging and error tracking.
- Created a new GoogleGeocodingService class for Google Maps geocoding with structured logging.
- Added tests for the useAiAnalysis hook to ensure proper functionality and error handling.
- Updated FlyerCorrectionTool tests to remove unused error notification.
- Enhanced ProfileManager tests and component to include points in user profile.
- Fixed error handling in ProfileManager to correctly log error messages.
- Adjusted AI routes tests to ensure proper mocking and added missing properties in mock responses.
- Refined AI routes to improve error message extraction and payload handling.
- Cleaned up gamification routes tests by removing unnecessary parameters.
- Simplified public routes by removing unused parameters in async handlers.
- Improved system routes tests to handle exec command callbacks more robustly.
- Updated user routes tests to remove unnecessary middleware parameters.
- Enhanced AI API client tests to use File objects for simulating uploads.
- Modified AI service tests to improve type safety and mock implementations.
- Refined database service tests to ensure proper type assertions and mock setups.
- Updated express type definitions for better clarity and organization.
- Cleaned up notification service tests to mock local re-exports instead of library directly.