@ffflorian/api-client 2.1.6 → 2.1.8
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/README.md +1 -1
- package/dist/APIClient.d.ts +2 -5
- package/dist/types.d.ts +8 -4
- package/package.json +2 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# api-client [](https://www.gnu.org/licenses/gpl-3.0) [](https://www.npmjs.com/package/@ffflorian/api-client)
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A simple API client using fetch ([Node.js](https://nodejs.org/api/globals.html#fetch) / [Web](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)).
|
|
4
4
|
|
|
5
5
|
## Prerequisites
|
|
6
6
|
|
package/dist/APIClient.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import type { APIResponse, BasicRequestOptions, ApiClientConfig,
|
|
1
|
+
import type { APIResponse, BasicRequestOptions, ApiClientConfig, Interceptors, RequestOptions } from './types.js';
|
|
2
2
|
export declare class APIClient {
|
|
3
3
|
private baseUrl;
|
|
4
4
|
private config?;
|
|
5
|
-
interceptors:
|
|
6
|
-
request: RequestInterceptor[];
|
|
7
|
-
response: ResponseInterceptor[];
|
|
8
|
-
};
|
|
5
|
+
interceptors: Interceptors;
|
|
9
6
|
constructor(baseUrl: string, config?: ApiClientConfig | undefined);
|
|
10
7
|
setBaseURL(baseUrl: string): void;
|
|
11
8
|
setConfig(config: Partial<RequestInit>): void;
|
package/dist/types.d.ts
CHANGED
|
@@ -11,12 +11,16 @@ export type ApiClientConfig = Partial<Omit<RequestInit, 'method'>> & {
|
|
|
11
11
|
username: string;
|
|
12
12
|
};
|
|
13
13
|
};
|
|
14
|
-
export type BasicRequestOptions = Omit<RequestOptions, 'method'>;
|
|
15
|
-
export type RequestInitWithMethod = Required<Pick<RequestInit, 'method'>> & Omit<RequestInit, 'method'>;
|
|
16
|
-
export type RequestInterceptor = (url: URL, options: RequestInitWithMethod) => RequestInitWithMethod | Promise<RequestInitWithMethod>;
|
|
17
|
-
export type ResponseInterceptor = (response: Response) => void | Promise<void>;
|
|
18
14
|
export interface APIResponse<T> {
|
|
19
15
|
data: T;
|
|
20
16
|
headers: Headers;
|
|
21
17
|
status: number;
|
|
22
18
|
}
|
|
19
|
+
export type BasicRequestOptions = Omit<RequestOptions, 'method'>;
|
|
20
|
+
export interface Interceptors {
|
|
21
|
+
request: RequestInterceptor[];
|
|
22
|
+
response: ResponseInterceptor[];
|
|
23
|
+
}
|
|
24
|
+
export type RequestInitWithMethod = Required<Pick<RequestInit, 'method'>> & Omit<RequestInit, 'method'>;
|
|
25
|
+
export type RequestInterceptor = (url: URL, options: RequestInitWithMethod) => RequestInitWithMethod | Promise<RequestInitWithMethod>;
|
|
26
|
+
export type ResponseInterceptor = (response: Response) => void | Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Florian Imdahl <git@ffflorian.de>",
|
|
3
|
-
"description": "
|
|
3
|
+
"description": "A simple API client using fetch",
|
|
4
4
|
"devDependencies": {
|
|
5
5
|
"rimraf": "6.1.2",
|
|
6
6
|
"typescript": "5.9.3"
|
|
@@ -15,7 +15,6 @@
|
|
|
15
15
|
"keywords": [
|
|
16
16
|
"api-client",
|
|
17
17
|
"fetch",
|
|
18
|
-
"cli",
|
|
19
18
|
"typescript"
|
|
20
19
|
],
|
|
21
20
|
"license": "GPL-3.0",
|
|
@@ -29,5 +28,5 @@
|
|
|
29
28
|
"test": "exit 0"
|
|
30
29
|
},
|
|
31
30
|
"type": "module",
|
|
32
|
-
"version": "2.1.
|
|
31
|
+
"version": "2.1.8"
|
|
33
32
|
}
|