@hapaul/api 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1421,6 +1421,7 @@ type ResponseData<T extends PathsWithMethod<paths, M>, M extends Methods> = Pars
|
|
|
1421
1421
|
type ResponseError<T extends PathsWithMethod<paths, M>, M extends Methods> = ErrorResponse<ResponseObjectMap<paths[T][M]>, `${string}/${string}`>;
|
|
1422
1422
|
type ClientConfig = {
|
|
1423
1423
|
baseUrl?: string;
|
|
1424
|
+
fetch?: typeof fetch;
|
|
1424
1425
|
};
|
|
1425
1426
|
type RequestConfig<T extends PathsWithMethod<paths, M>, M extends Methods, C = {}> = ClientConfig & {
|
|
1426
1427
|
method: M;
|
|
@@ -1446,6 +1447,7 @@ interface Middleware<C> {
|
|
|
1446
1447
|
declare class Client<C> {
|
|
1447
1448
|
private middlewares;
|
|
1448
1449
|
private baseUrl;
|
|
1450
|
+
private fetch;
|
|
1449
1451
|
constructor(config?: ClientConfig);
|
|
1450
1452
|
use(middleware: Middleware<C>): void;
|
|
1451
1453
|
request<T extends PathsWithMethod<paths, M>, M extends Methods>(method: M, path: T, ...params: RequestParams<T, M, C>): RequestResponse<T, M>;
|
package/dist/index.js
CHANGED
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
var Client = class {
|
|
3
3
|
middlewares;
|
|
4
4
|
baseUrl;
|
|
5
|
+
fetch;
|
|
5
6
|
constructor(config) {
|
|
6
7
|
this.middlewares = [];
|
|
7
8
|
this.baseUrl = config?.baseUrl ?? "";
|
|
9
|
+
this.fetch = config?.fetch ?? fetch;
|
|
8
10
|
}
|
|
9
11
|
use(middleware) {
|
|
10
12
|
this.middlewares.push(middleware);
|
|
@@ -28,7 +30,7 @@ var Client = class {
|
|
|
28
30
|
if (!contentType) headers.set("Content-Type", "application/json");
|
|
29
31
|
try {
|
|
30
32
|
const serializedBody = defaultBodySerializer(body, headers);
|
|
31
|
-
let response = await fetch(url, {
|
|
33
|
+
let response = await this.fetch(url, {
|
|
32
34
|
...requestConfig,
|
|
33
35
|
body: serializedBody,
|
|
34
36
|
method: method.toUpperCase(),
|