This repository was archived by the owner on Feb 2, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +72
-48
lines changed Expand file tree Collapse file tree 4 files changed +72
-48
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3
3
"version" : " 2.1.0" ,
4
4
"description" : " Forward your HTTP request to another server." ,
5
5
"main" : " index.js" ,
6
- "types" : " index.d.ts" ,
6
+ "types" : " types/ index.d.ts" ,
7
7
"scripts" : {
8
- "lint" : " npx standard" ,
9
- "test" : " nyc mocha test/*.test.js" ,
8
+ "lint" : " standard" ,
9
+ "test" : " npm run test:unit && npm run test:typescript" ,
10
+ "test:unit" : " nyc mocha test/*.test.js" ,
11
+ "test:typescript" : " tsd" ,
10
12
"bench" : " ( node benchmark/service.js & node benchmark/fast-proxy-0http-gateway.js & (sleep 5 && wrk -t8 -c8 -d30s http://127.0.0.1:8080/service/hi) )"
11
13
},
12
14
"repository" : {
22
24
"files" : [
23
25
" LICENSE" ,
24
26
" README.md" ,
25
- " index.d.ts" ,
27
+ " types/ index.d.ts" ,
26
28
" index.js" ,
27
29
" lib/"
28
30
],
33
35
},
34
36
"homepage" : " https://github.com/fastify/fast-proxy" ,
35
37
"devDependencies" : {
38
+ "@types/node" : " ^18.11.10" ,
36
39
"0http" : " ^3.1.1" ,
37
40
"body-parser" : " ^1.19.0" ,
38
41
"chai" : " ^4.3.4" ,
45
48
"restana" : " ^4.9.1" ,
46
49
"self-cert" : " ^2.0.0" ,
47
50
"standard" : " ^17.0.0" ,
48
- "supertest" : " ^6.1.6"
51
+ "supertest" : " ^6.1.6" ,
52
+ "tsd" : " ^0.25.0"
49
53
},
50
54
"dependencies" : {
51
55
"end-of-stream" : " ^1.4.4" ,
Original file line number Diff line number Diff line change
1
+ import * as Http from 'http' ;
2
+ import * as Https from 'https' ;
3
+ import * as Undici from 'undici' ;
4
+
5
+ type Stream = ReadableStream | WritableStream
6
+
7
+ type FastProxy = ( options ?: fastProxy . FastProxyOptions ) => {
8
+ proxy (
9
+ originReq : Http . IncomingMessage ,
10
+ originRes : Http . ServerResponse ,
11
+ source : string ,
12
+ opts ?: {
13
+ base ?: string ;
14
+ onResponse ?( req : Http . IncomingMessage , res : Http . ServerResponse , stream : Stream ) : void ;
15
+ rewriteRequestHeaders ?( req : Http . IncomingMessage , headers : Http . IncomingHttpHeaders ) : Http . IncomingHttpHeaders ;
16
+ rewriteHeaders ?( headers : Http . OutgoingHttpHeaders ) : Http . OutgoingHttpHeaders ;
17
+ request ?: Http . RequestOptions ;
18
+ queryString ?: string ;
19
+ }
20
+ ) : void ;
21
+ close ( ) : void ;
22
+ }
23
+
24
+ declare namespace fastProxy {
25
+ interface QueryStringModule {
26
+ stringify ( value : any ) : string ;
27
+ parse ( value : string ) : any ;
28
+ }
29
+
30
+ export interface FastProxyOptions {
31
+ base ?: string ;
32
+ http2 ?: boolean ;
33
+ undici ?: Undici . Pool . Options ;
34
+ cacheURLs ?: number ;
35
+ requests ?: {
36
+ http ?: Http . Agent ,
37
+ https ?: Https . Agent
38
+ } ;
39
+ keepAliveMsecs ?: number ;
40
+ maxSockets ?: number ;
41
+ rejectUnauthorized ?: boolean ;
42
+ queryString ?: QueryStringModule ;
43
+ }
44
+
45
+ export const fastProxy : FastProxy
46
+ export { fastProxy as default }
47
+ }
48
+
49
+ declare function fastProxy ( ...params : Parameters < FastProxy > ) : ReturnType < FastProxy >
50
+ export = fastProxy
Original file line number Diff line number Diff line change
1
+ import fastProxy , { fastProxy as fastProxyNamed } from '..'
2
+ import { expectAssignable , expectType } from 'tsd'
3
+
4
+ const proxy = fastProxy ( {
5
+ base : 'http://127.0.0.1:3000'
6
+ } )
7
+ fastProxyNamed ( {
8
+ base : 'http://127.0.0.1:3000'
9
+ } )
10
+
11
+ expectType < typeof fastProxyNamed > ( fastProxy )
12
+ expectType < ( ) => void > ( proxy . close )
13
+ expectAssignable < Function > ( proxy . proxy )
You can’t perform that action at this time.
0 commit comments