File tree Expand file tree Collapse file tree 3 files changed +9
-22
lines changed Expand file tree Collapse file tree 3 files changed +9
-22
lines changed Original file line number Diff line number Diff line change 1
1
/// <reference types="node" />
2
2
3
3
import {
4
- FastifyRequest ,
5
- RawServerBase ,
6
4
FastifyPlugin ,
7
- FastifyError ,
8
- FastifyReply
5
+ preHandlerHookHandler
9
6
} from "fastify" ;
10
7
11
8
export interface FastifyHttpProxyOptions {
@@ -14,16 +11,8 @@ export interface FastifyHttpProxyOptions {
14
11
rewritePrefix ?: string ;
15
12
http2 ?: boolean ;
16
13
proxyPayloads ?: boolean ;
17
- preHandler ?: (
18
- request : FastifyRequest < RawServerBase > ,
19
- reply : FastifyReply < RawServerBase > ,
20
- next : ( err ?: FastifyError | undefined ) => void
21
- ) => void ;
22
- beforeHandler ?: (
23
- request : FastifyRequest < RawServerBase > ,
24
- reply : FastifyReply < RawServerBase > ,
25
- next : ( err ?: FastifyError | undefined ) => void
26
- ) => void ;
14
+ preHandler ?: preHandlerHookHandler ;
15
+ beforeHandler ?: preHandlerHookHandler ;
27
16
config ?: Object ;
28
17
replyOptions ?: Object ;
29
18
}
Original file line number Diff line number Diff line change 4
4
"description" : " proxy http requests, for Fastify" ,
5
5
"main" : " index.js" ,
6
6
"scripts" : {
7
- "test" : " standard | snazzy && tap test/*.js" ,
7
+ "test" : " standard | snazzy && tap test/*.js && npm run typescript " ,
8
8
"lint:typescript" : " standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts" ,
9
9
"typescript" : " tsd"
10
10
},
Original file line number Diff line number Diff line change 1
- import fastify from "fastify" ;
1
+ import fastify , { RawReplyDefaultExpression , RawRequestDefaultExpression } from "fastify" ;
2
2
import fastifyHttpProxy from ".." ;
3
3
import { expectType } from "tsd" ;
4
- import { IncomingMessage , ServerResponse } from "http" ;
5
- import { Http2ServerRequest , Http2ServerResponse } from "http2" ;
6
4
7
5
const app = fastify ( ) ;
8
6
@@ -18,11 +16,11 @@ app.register(fastifyHttpProxy, {
18
16
config : { key : 1 } ,
19
17
replyOptions : { opt : "a" } ,
20
18
preHandler : ( request , reply ) => {
21
- expectType < IncomingMessage | Http2ServerRequest > ( request . raw ) ;
22
- expectType < ServerResponse | Http2ServerResponse > ( reply . raw ) ;
19
+ expectType < RawRequestDefaultExpression > ( request . raw ) ;
20
+ expectType < RawReplyDefaultExpression > ( reply . raw ) ;
23
21
} ,
24
22
beforeHandler : ( request , reply ) => {
25
- expectType < IncomingMessage | Http2ServerRequest > ( request . raw ) ;
26
- expectType < ServerResponse | Http2ServerResponse > ( reply . raw ) ;
23
+ expectType < RawRequestDefaultExpression > ( request . raw ) ;
24
+ expectType < RawReplyDefaultExpression > ( reply . raw ) ;
27
25
}
28
26
} ) ;
You can’t perform that action at this time.
0 commit comments