forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
needle.d.ts
99 lines (81 loc) · 3.19 KB
/
needle.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// Type definitions for needle 0.7.8
// Project: https://github.com/tomas/needle
// Definitions by: San Chen <https://github.com/bigsan>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../node/node.d.ts" />
declare module Needle {
interface ReadableStream extends NodeJS.ReadableStream {
}
interface Callback {
(error: Error, response: any, body: any): void;
}
interface RequestOptions {
timeout?: number;
follow?: number;
follow_max?: number;
multipart?: boolean;
proxy?: string;
agent?: string;
headers?: HttpHeaderOptions;
auth?: string; // auto | digest | basic (default)
json?: boolean;
// These properties are overwritten by those in the 'headers' field
compressed?: boolean;
cookies?: { [name: string]: any; };
// Overwritten if present in the URI
username?: string;
password?: string;
}
interface ResponseOptions {
decode?: boolean;
parse?: boolean;
output?: any;
}
interface HttpHeaderOptions {
cookies?: { [name: string]: any; };
compressed?: boolean;
accept?: string;
connection?: string;
user_agent?: string;
// Overwritten if present in the URI
username?: string;
password?: string;
}
interface TLSOptions {
pfx?: any;
key?: any;
passphrase?: string;
cert?: any;
ca?: any;
ciphers?: any;
rejectUnauthorized?: boolean;
secureProtocol?: any;
}
interface NeedleOptions extends RequestOptions, ResponseOptions, HttpHeaderOptions, TLSOptions {
}
interface NeedleStatic {
defaults(options?: any): void;
head(url: string): ReadableStream;
head(url: string, callback?: Callback): ReadableStream;
head(url: string, options?: RequestOptions, callback?: Callback): ReadableStream;
get(url: string): ReadableStream;
get(url: string, callback?: Callback): ReadableStream;
get(url: string, options?: RequestOptions, callback?: Callback): ReadableStream;
post(url: string, data: any): ReadableStream;
post(url: string, data: any, callback?: Callback): ReadableStream;
post(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream;
put(url: string, data: any): ReadableStream;
put(url: string, data: any, callback?: Callback): ReadableStream;
put(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream;
delete(url: string, data: any): ReadableStream;
delete(url: string, data: any, callback?: Callback): ReadableStream;
delete(url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream;
request(method: string, url: string, data: any): ReadableStream;
request(method: string, url: string, data: any, callback?: Callback): ReadableStream;
request(method: string, url: string, data: any, options?: RequestOptions, callback?: Callback): ReadableStream;
}
}
declare module "needle" {
var needle: Needle.NeedleStatic;
export = needle;
}