⬆️ (csmr-rie): use fetch instead of axios (third attempt)#1124
Draft
douglasduteil wants to merge 1 commit into
Draft
⬆️ (csmr-rie): use fetch instead of axios (third attempt)#1124douglasduteil wants to merge 1 commit into
douglasduteil wants to merge 1 commit into
Conversation
**Problem** `csmr-rie` was hardwired to axios with no way to swap the HTTP client without code changes. Native fetch avoids an extra dependency and uses `AbortSignal.timeout()` for per-request cancellation, but there was no abstraction to select the strategy at runtime. **Proposal** Introduce a `FetchHttpModule` that mirrors `HttpModule.registerAsync` and exposes `HttpService` backed by `FetchHttpService`. A strategy record keyed by `HttpClient` (`"axios" | "fetch"`) selects the active module at startup. The choice is driven by `USE_HTTP_CLIENT` env var, validated through `ConfigService`, defaulting to `"axios"`.
d42c4b7 to
c7e6704
Compare
Contributor
Author
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.
Problem
csmr-riewas hardwired to axios with no way to swap the HTTP client without code changes. Native fetch avoids an extra dependency and usesAbortSignal.timeout()for per-request cancellation, but there was no abstraction to select the strategy at runtime.Proposal
Introduce a
FetchHttpModulethat mirrorsHttpModule.registerAsyncand exposesHttpServicebacked byFetchHttpService. A strategy record keyed byHttpClient("axios" | "fetch") selects the active module at startup. The choice is driven byUSE_HTTP_CLIENTenv var, validated throughConfigService, defaulting to"axios".Changes
FetchHttpService: native fetch wrapped asObservable<HttpResponse>, withAbortSignal.timeout(requestTimeout)thunk for per-request signalsFetchHttpModule.registerAsync: mirrorsHttpModule.registerAsyncAPI; injectsFETCH_FNtoken for testability without global mutationCsmrHttpProxyModule: strategy pattern — namedaxiosStrategy/fetchStrategyconstants,strategies[httpClient]lookup inregister()CsmrHttpProxyConfig:httpClientfield with@IsIn(["axios", "fetch"])validationapp.module.tsdeleted — unnecessary indirection for a single-feature apphybridge-rie.env: documentsUSE_HTTP_CLIENT=axiosdefault