From b799f187a6d5ad4c0001db703a0d77a14b7907d6 Mon Sep 17 00:00:00 2001 From: Bas Meeuwissen Date: Fri, 3 Jan 2025 14:54:14 +0100 Subject: [PATCH] #585: last feedback --- packages/http/src/FetchHttpClient.ts | 2 +- packages/http/src/HttpRemoteBuilder.ts | 4 ++-- packages/http/src/interfaces/HttpClient.ts | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/http/src/FetchHttpClient.ts b/packages/http/src/FetchHttpClient.ts index e07f2010..2af4973f 100644 --- a/packages/http/src/FetchHttpClient.ts +++ b/packages/http/src/FetchHttpClient.ts @@ -3,7 +3,7 @@ import HttpClient from './interfaces/HttpClient'; export default class FetchHttpClient implements HttpClient { - async execute(url: string, options: object): Promise + async execute(url: string, options?: RequestInit): Promise { return fetch(url, options); } diff --git a/packages/http/src/HttpRemoteBuilder.ts b/packages/http/src/HttpRemoteBuilder.ts index 350254e5..aed6f931 100644 --- a/packages/http/src/HttpRemoteBuilder.ts +++ b/packages/http/src/HttpRemoteBuilder.ts @@ -9,9 +9,9 @@ export default class HttpRemoteBuilder implements RemoteBuilder { readonly #httpClient: HttpClient; - constructor() + constructor(httpClient: HttpClient = new FetchHttpClient()) { - this.#httpClient = new FetchHttpClient(); + this.#httpClient = httpClient; } build(url: string): Remote diff --git a/packages/http/src/interfaces/HttpClient.ts b/packages/http/src/interfaces/HttpClient.ts index 431f3cbe..480ab324 100644 --- a/packages/http/src/interfaces/HttpClient.ts +++ b/packages/http/src/interfaces/HttpClient.ts @@ -1,7 +1,7 @@ interface HttpClient { - execute(url: string, options: object): Promise; + execute(url: string, options?: RequestInit): Promise; } export default HttpClient;