@@ -2,40 +2,44 @@ import * as Http from 'http';
22import * as Https from 'https' ;
33import { Stream } from 'pump' ;
44
5- type Options = {
5+ export type Options = {
66 base ?: string ;
77 cacheURLs ?: number ;
88 requests ?: {
9- http ?: Http . Agent ,
10- https ?: Https . Agent
9+ http ?: Http . Agent ;
10+ https ?: Https . Agent ;
1111 } ;
1212 keepAliveMsecs ?: number ;
1313 maxSockets ?: number ;
1414 rejectUnauthorized ?: boolean ;
15- }
15+ } ;
1616
17- type ProxyRequestResponse = {
17+ export type ProxyRequestResponse = {
1818 statusCode : Number ;
1919 headers : Http . OutgoingHttpHeaders ;
2020 stream : Stream ;
21+ } ;
22+
23+ export type ProxyOptions = {
24+ base ?: string ;
25+ onClientConnectionTerminated ?( res : Http . ServerResponse , err : Error , response : ProxyRequestResponse ) : void ;
26+ onResponse ?( req : Http . IncomingMessage , res : Http . ServerResponse , stream : Stream ) : void ;
27+ rewriteRequestHeaders ?( req : Http . IncomingMessage , headers : Http . IncomingHttpHeaders ) : Http . IncomingHttpHeaders ;
28+ rewriteHeaders ?( headers : Http . OutgoingHttpHeaders ) : Http . OutgoingHttpHeaders ;
29+ request ?: Http . RequestOptions ;
30+ queryString ?: string ;
2131}
2232
23- declare function fastProxy ( options ?: Options ) : {
33+ export type FastProxy = {
2434 proxy (
2535 originReq : Http . IncomingMessage ,
2636 originRes : Http . ServerResponse ,
2737 source : string ,
28- opts ?: {
29- base ?: string ;
30- onClientConnectionTerminated ?( res : Http . ServerResponse , err : Error , response : ProxyRequestResponse ) : void ;
31- onResponse ?( req : Http . IncomingMessage , res : Http . ServerResponse , stream : Stream ) : void ;
32- rewriteRequestHeaders ?( req : Http . IncomingMessage , headers : Http . IncomingHttpHeaders ) : Http . IncomingHttpHeaders ;
33- rewriteHeaders ?( headers : Http . OutgoingHttpHeaders ) : Http . OutgoingHttpHeaders ;
34- request ?: Http . RequestOptions ;
35- queryString ?: string ;
36- }
38+ opts ?: ProxyOptions
3739 ) : void ;
3840 close ( ) : void ;
3941}
4042
43+ declare function fastProxy ( options ?: Options ) : FastProxy
44+
4145export default fastProxy
0 commit comments