This repository has been archived by the owner on Jan 30, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
92 lines (77 loc) · 2.23 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
import {ServerResponse, IncomingMessage} from "http";
import type {Url} from 'url';
import httpProxy from "http-proxy";
interface CorsAnywhereOptions {
/**
* Function that specifies the proxy to use.
* Default: env checking
*/
getProxyForUrl: (url: string | Url) => string;
/**
* Maximum number of redirects to be followed.
* Default: 5
*/
maxRedirects: number;
/**
* Requests from these origins will be blocked.
* Default: []
*/
originBlacklist: string[];
/**
* If non-empty, requests not from an origin in this list will be blocked.
* Default: []
*/
originWhitelist: string[];
/**
* If non-empty, function would be called with origin URL.
* To when return on true to no be proxied.
* Default: none
*/
checkRateLimit: (origin: string) => boolean;
/**
* Require headers on incoming requests.
* Default: []
*/
requireHeader: string[];
/**
* Strip these request headers.
* Default: []
*/
removeHeaders: string[];
/**
* Set these request headers.
* Default: {}
*/
setHeaders: {[header: string]: string};
/**
* When specified, an Access-Control-Max-Age header with this value (in seconds) will be added.
* Default: '0'
*/
corsMaxAge: number;
/**
* Callback that is called when the Response body has been fully received.
* It gives a decompressed body and origin of url from body.
* And expects an modified decompressed body back.
* Default: none
*/
onReceiveResponseBody: (body: string, origin: string) => string;
}
interface RateLimitOptions {
/**
* Amount of request per Defined-Period.
* Default: 10
*/
maxRequestsPerPeriod: number;
/**
* Define how many minutes each period last.
* Default: 1
*/
periodInMinutes: number;
/**
* Sites to whitelist.
* Default: []
*/
sites: (string|RegExp)[];
}
export declare function createRateLimitChecker(options: Partial<RateLimitOptions>): (host: string) => boolean;
export declare function getHandler(options: Partial<CorsAnywhereOptions>, proxy: httpProxy): (req: IncomingMessage, res: ServerResponse) => void;