-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathindex.d.ts
More file actions
88 lines (64 loc) · 2.06 KB
/
index.d.ts
File metadata and controls
88 lines (64 loc) · 2.06 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
declare module "react-native-http-bridge-refurbished" {
function start(
port: number,
serviceName: string,
callback: (request: {
requestId: string;
postData?: {};
type: string;
url: string;
}) => void
): void;
function stop(): void;
function respond(
requestId: string,
code: number,
type: string,
body: string
): void;
export type RawRequest = {
requestId: string;
postData?: {};
type: string;
url: string;
};
export class Request<T> {
public readonly requestId: string;
public readonly postData?: {};
public readonly type: string;
public readonly url: string;
constructor(rawRequest: RawRequest);
public get data();
}
export class Response {
private readonly requestId: string;
public closed: boolean;
constructor(requestId: string);
public send(code: number, type: string, body: string);
public json(obj: object, code?: number);
public html(html: string, code?: number);
}
export type HttpCallback<T> = (
request: Request<T>,
response: Response,
) => Promise<object | void>;
export type HttpCallbackContainer<T> = {
method: string;
url: string;
callback: HttpCallback<T>;
};
export class BridgeServer {
public static server: BridgeServer;
public serviceName: string;
private callbacks: HttpCallbackContainer<any>[];
constructor(serviceName: string, devMode?: boolean);
public get(url: string, callback: HttpCallback<any>);
public post<T>(url: string, callback: HttpCallback<T>);
public put<T>(url: string, callback: HttpCallback<T>);
public delete<T>(url: string, callback: HttpCallback<T>);
public patch<T>(url: string, callback: HttpCallback<T>);
public use(callback: HttpCallback<any>);
public listen(port: number);
public stop();
}
}