Repository navigation
Expand file tree
/
Copy pathindex.ts
More file actions
88 lines (82 loc) · 2.02 KB
/
Copy pathindex.ts
File metadata and controls
88 lines (82 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import deleteReq from './core/delete';
import get from './core/get';
import head from './core/head';
import patch from './core/patch';
import post from './core/post';
import put from './core/put';
import use from './core/use';
import useOptions from './core/useOptions';
import cors from './middleware/cors';
import kneepads from './middleware/kneepads';
import timeTook from './middleware/timeTook';
import AxleCancelMark from './models/cancelMark';
import AxleRequest from './models/request';
import AxleResponse from './models/response';
export namespace AxleTypes {
interface AxleHeaders {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
'Content-Type'?: string;
}
export interface AxleOptions {
mode?: 'no-cors' | 'cors' | 'same-origin';
cache?:
| 'no-cache'
| 'default'
| 'reload'
| 'force-cache'
| 'only-if-cached';
credentials?: RequestCredentials;
headers?: AxleHeaders;
redirect?: 'manual' | 'follow' | 'error';
referrer?: string;
referrerPolicy?:
| 'no-referrer'
| 'no-referrer-when-downgrade'
| 'origin'
| 'origin-when-cross-origin'
| 'same-origin'
| 'strict-origin'
| 'strict-origin-when-cross-origin'
| 'unsafe-url';
body?: string | FormData;
keepalive?: boolean;
signal?: AbortSignal | null;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
window?: any;
integrity?: string;
handleStatus?: (status: number, statusMessage: string) => boolean;
}
export type AxleMiddleware = (
req: AxleRequest,
res: AxleResponse
) => unknown;
export interface AxleError {
status: number;
message: string;
response: AxleResponse;
request: AxleRequest;
}
}
const Axle = {
post: post,
get: get,
delete: deleteReq,
put: put,
patch: patch,
head: head,
all: (promises: Promise<AxleResponse>[]) => {
return Promise.all(promises);
},
cancelMark: AxleCancelMark,
use: use,
useOptions: useOptions,
middleware: {
timeTook: timeTook,
},
middlewareOptions: {
cors: cors,
kneepads: kneepads,
},
};
export default Axle;