Skip to content

Commit 514ab2c

Browse files
committed
refactor(api-client): Move interface into its own file
1 parent 2530881 commit 514ab2c

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

packages/api-client/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@
2020
"license": "GPL-3.0",
2121
"module": "dist/index.js",
2222
"name": "@ffflorian/api-client",
23-
"publishConfig": {
24-
"access": "public"
25-
},
2623
"repository": "https://github.com/ffflorian/node-packages/tree/main/packages/api-client",
2724
"scripts": {
2825
"build": "tsc -p tsconfig.build.json",

packages/api-client/src/APIClient.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import type {
22
APIResponse,
33
BasicRequestOptions,
44
ApiClientConfig,
5-
RequestInterceptor,
6-
ResponseInterceptor,
5+
Interceptors,
76
RequestInitWithMethod,
87
RequestOptions,
98
} from './types.js';
109

1110
export class APIClient {
12-
public interceptors: {request: RequestInterceptor[]; response: ResponseInterceptor[]} = {
11+
public interceptors: Interceptors = {
1312
request: [],
1413
response: [],
1514
};

packages/api-client/src/types.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ export interface RequestOptions {
2222

2323
export type ApiClientConfig = Partial<Omit<RequestInit, 'method'>> & {auth?: {password: string; username: string}};
2424

25+
export interface APIResponse<T> {
26+
data: T;
27+
headers: Headers;
28+
status: number;
29+
}
30+
2531
export type BasicRequestOptions = Omit<RequestOptions, 'method'>;
2632

33+
export interface Interceptors {
34+
request: RequestInterceptor[];
35+
response: ResponseInterceptor[];
36+
}
37+
2738
export type RequestInitWithMethod = Required<Pick<RequestInit, 'method'>> & Omit<RequestInit, 'method'>;
2839

2940
export type RequestInterceptor = (
@@ -32,9 +43,3 @@ export type RequestInterceptor = (
3243
) => RequestInitWithMethod | Promise<RequestInitWithMethod>;
3344

3445
export type ResponseInterceptor = (response: Response) => void | Promise<void>;
35-
36-
export interface APIResponse<T> {
37-
data: T;
38-
headers: Headers;
39-
status: number;
40-
}

0 commit comments

Comments
 (0)