File tree Expand file tree Collapse file tree 3 files changed +13
-12
lines changed
Expand file tree Collapse file tree 3 files changed +13
-12
lines changed Original file line number Diff line number Diff line change 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" ,
Original file line number Diff line number Diff 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
1110export class APIClient {
12- public interceptors : { request : RequestInterceptor [ ] ; response : ResponseInterceptor [ ] } = {
11+ public interceptors : Interceptors = {
1312 request : [ ] ,
1413 response : [ ] ,
1514 } ;
Original file line number Diff line number Diff line change @@ -22,8 +22,19 @@ export interface RequestOptions {
2222
2323export 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+
2531export type BasicRequestOptions = Omit < RequestOptions , 'method' > ;
2632
33+ export interface Interceptors {
34+ request : RequestInterceptor [ ] ;
35+ response : ResponseInterceptor [ ] ;
36+ }
37+
2738export type RequestInitWithMethod = Required < Pick < RequestInit , 'method' > > & Omit < RequestInit , 'method' > ;
2839
2940export type RequestInterceptor = (
@@ -32,9 +43,3 @@ export type RequestInterceptor = (
3243) => RequestInitWithMethod | Promise < RequestInitWithMethod > ;
3344
3445export type ResponseInterceptor = ( response : Response ) => void | Promise < void > ;
35-
36- export interface APIResponse < T > {
37- data : T ;
38- headers : Headers ;
39- status : number ;
40- }
You can’t perform that action at this time.
0 commit comments