Skip to content

⬆️ (csmr-rie): use fetch instead of axios (third attempt) - #1124

Closed
douglasduteil wants to merge 1 commit into
mainfrom
douglasduteil/Use-fetch-instead-of-axios-third-attempt
Closed

⬆️ (csmr-rie): use fetch instead of axios (third attempt)#1124
douglasduteil wants to merge 1 commit into
mainfrom
douglasduteil/Use-fetch-instead-of-axios-third-attempt

Conversation

@douglasduteil

@douglasduteil douglasduteil commented Apr 21, 2026

Copy link
Copy Markdown
Contributor

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".

Changes

  • FetchHttpService: native fetch wrapped as Observable<HttpResponse>, with AbortSignal.timeout(requestTimeout) thunk for per-request signals
  • FetchHttpModule.registerAsync: mirrors HttpModule.registerAsync API; injects FETCH_FN token for testability without global mutation
  • CsmrHttpProxyModule: strategy pattern — named axiosStrategy/fetchStrategy constants, strategies[httpClient] lookup in register()
  • CsmrHttpProxyConfig: httpClient field with @IsIn(["axios", "fetch"]) validation
  • app.module.ts deleted — unnecessary indirection for a single-feature app
  • hybridge-rie.env: documents USE_HTTP_CLIENT=axios default

**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"`.
@douglasduteil
douglasduteil force-pushed the douglasduteil/Use-fetch-instead-of-axios-third-attempt branch from d42c4b7 to c7e6704 Compare April 21, 2026 08:06
@douglasduteil douglasduteil changed the title ⬆️ (csmr-rie): use fetch instead of axios ⬆️ (csmr-rie): use fetch instead of axios (third attempt) Apr 21, 2026
@douglasduteil
douglasduteil marked this pull request as draft April 21, 2026 10:14
@douglasduteil

Copy link
Copy Markdown
Contributor Author

Linked to #1069 #1088

@douglasduteil

Copy link
Copy Markdown
Contributor Author

Duplicate

@douglasduteil
douglasduteil deleted the douglasduteil/Use-fetch-instead-of-axios-third-attempt branch June 15, 2026 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant