This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
75 lines (66 loc) · 1.64 KB
/
index.d.ts
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
type ProtocolVersion =
| 'http/1.0'
| 'http/1.1'
| 'http/2.0';
type Method =
| 'get' | 'GET'
| 'delete' | 'DELETE'
| 'head' | 'HEAD'
| 'options' | 'OPTIONS'
| 'post' | 'POST'
| 'put' | 'PUT'
| 'patch' | 'PATCH';
type ResponseType =
| 'json'
| 'text'
| 'stream';
interface NSendRequestOptions {
protocolVersion?: ProtocolVersion,
method?: Method;
baseUrl?: string;
url?: string;
params?: any;
auth?: {
username: string;
password: string;
};
headers?: any;
data?: any;
timeout?: number;
maxContentLength?: number;
maxRedirects?: number;
responseType?: ResponseType;
responseEncoding?: String;
}
interface NSendResponse {
statusCode: number;
statusText: string;
headers: any;
request?: any;
data?: any;
}
interface NSendError extends Error {
options: NSendRequestOptions;
code?: string;
request?: any;
response?: NSendResponse;
}
interface NSendPromise extends Promise<NSendResponse> {
}
interface NSendCore {
getInstance(): NSendCore;
send(options: NSendRequestOptions): NSendPromise;
}
interface NSendInstance {
(options: NSendRequestOptions): NSendPromise;
get(url: string, options?: NSendRequestOptions): NSendPromise;
delete(url: string, options?: NSendRequestOptions): NSendPromise;
head(url: string, options?: NSendRequestOptions): NSendPromise;
post(url: string, data?: any, options?: NSendRequestOptions): NSendPromise;
put(url: string, data?: any, options?: NSendRequestOptions): NSendPromise;
patch(url: string, data?: any, options?: NSendRequestOptions): NSendPromise;
NSend: NSendCore;
NSendError: NSendError
}
declare const NSend: NSendInstance;
export = NSend;