Skip to content

Commit

Permalink
Fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ejsmith committed May 9, 2024
1 parent 90a0d09 commit 10d20ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
1 change: 0 additions & 1 deletion src/FetchClient.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { assert, assertEquals, assertFalse } from "@std/assert";
import {
defaultProvider,
defaultProvider as provider,
FetchClient,
ProblemDetails,
Expand Down
10 changes: 10 additions & 0 deletions src/FetchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@ export class FetchClient {
return this.requestCount > 0;
}

/**
* Adds one or more middleware functions to the FetchClient's middleware pipeline.
* Middleware functions are executed in the order they are added.
*
* @param mw - The middleware functions to add.
*/
public use(...mw: FetchClientMiddleware[]): void {
this.#middleware.push(...mw);
}

/**
* Sends a GET request to the specified URL.
*
Expand Down
9 changes: 6 additions & 3 deletions src/FetchClientProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,11 @@ export class FetchClientProvider {

/**
* Creates a new instance of FetchClient using the current provider.
* @param options - The options to use for the new FetchClient instance. Options provided here will override the default options set on the provider.
* @returns A new instance of FetchClient.
*/
public getFetchClient(): FetchClient {
return new FetchClient({
public getFetchClient(options?: FetchClientOptions): FetchClient {
const o = {
defaultRequestOptions: this.#options.defaultRequestOptions,
baseUrl: this.#options.baseUrl,
cache: this.#cache,
Expand All @@ -92,7 +93,9 @@ export class FetchClientProvider {
modelValidator: this.#options.modelValidator,
accessTokenFunc: this.#options.accessTokenFunc,
providerCounter: this.#counter,
});
};
options = { ...o, ...options };
return new FetchClient(options);
}

/**
Expand Down

0 comments on commit 10d20ed

Please sign in to comment.