Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
This pull request refactors the frontend API layer to centralize HTTP logic, error handling, and authentication header injection. It introduces a singleton
httpClientwith interceptors, removes duplicated header and token logic from individual API calls, and adds a utility module for error and retry handling. Additionally, it cleans up unnecessary logging and streamlines request caching and deduplication.Centralized HTTP client and authentication:
httpClientinhttpClient.ts, which wraps all API calls with automatic authentication header injection, uniform error handling, and request/response interceptors. This eliminates the need for manualheaderBuilderandlocalStorage.getItem('token')calls across the codebase. (src/frontend/src/api/httpClient.ts, src/frontend/src/api/httpClient.tsR1-R246)apiClient.tsxto use the newhttpClient, simplifying the API interface and ensuring runtime base URL synchronization. (src/frontend/src/api/apiClient.tsx, src/frontend/src/api/apiClient.tsxL1-L103)headerBuilderfunction and all related manual header logic fromconfig.tsx. (src/frontend/src/api/config.tsx, src/frontend/src/api/config.tsxL100-L133)API utility functions:
apiUtils.tswith centralized helpers for error response construction, retry logic, request deduplication, and caching. This provides a single source of truth for common API patterns. (src/frontend/src/api/apiUtils.ts, src/frontend/src/api/apiUtils.tsR1-R149)httpClientfromindex.tsxfor use throughout the frontend. (src/frontend/src/api/index.tsx, src/frontend/src/api/index.tsxR4-R9)Logging and error handling cleanup:
apiService.tsx,config.tsx, andTeamSelector.tsxto reduce noise and improve clarity. (src/frontend/src/api/apiService.tsx, [1] [2] [3] [4];src/frontend/src/api/config.tsx, [5] [6];src/frontend/src/components/common/TeamSelector.tsx, [7] [8]These changes make the API layer more maintainable, consistent, and easier to extend for future features.
Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information