Skip to content

feat: support custom fetch implementation via option - #40

Merged
titan-ron merged 1 commit into
mainfrom
titan/fetch-override-option
Jul 20, 2026
Merged

feat: support custom fetch implementation via option#40
titan-ron merged 1 commit into
mainfrom
titan/fetch-override-option

Conversation

@titan-ron

Copy link
Copy Markdown
Collaborator

Summary

Adds support for overriding the fetch function via a client option. Callers can now inject a custom fetch implementation (for proxies, custom agents, retries, non-Node runtimes, or testing). Defaults to the global fetch when not provided.

Changes

  • src/lib/types.ts: add FetchFunction type alias and an optional fetch field on CreateClientOptions.
  • src/lib/sonar-client.ts: thread the custom fetch through createClient and SonarQubeClient, using globalThis.fetch.bind(globalThis) as the default. request() now calls this.fetchFn.
  • src/lib/sonar-client.spec.ts: new test asserting the custom fetch mock is used (URL/method/headers) and the global fetch is not.
  • README.md: document the new fetch option.

Validation

  • npm run lint:check
  • npm run format:check
  • npm test ✓ (14 passed)
  • npm run build

@github-code-quality

github-code-quality Bot commented Jul 19, 2026

Copy link
Copy Markdown

Code Coverage Overview

Languages: TypeScript

TypeScript / code-coverage/jest

The overall coverage remains at 67%, unchanged from the main branch.


Updated July 19, 2026 23:13 UTC
Code Coverage is in Public Preview. Learn more and provide us with your feedback.

@titan-ron
titan-ron force-pushed the titan/fetch-override-option branch from b2b92d6 to 14ba25d Compare July 19, 2026 22:58
@titan-ron
titan-ron force-pushed the titan/fetch-override-option branch from 14ba25d to 71ed7c0 Compare July 19, 2026 23:12
@titan-ron
titan-ron merged commit ff12161 into main Jul 20, 2026
12 checks passed
@titan-ron
titan-ron deleted the titan/fetch-override-option branch July 20, 2026 08:46
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.4.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant