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 11/// <reference types="node" />
22
33import {
4- FastifyRequest ,
5- RawServerBase ,
64 FastifyPlugin ,
7- FastifyError ,
8- FastifyReply
5+ preHandlerHookHandler
96} from "fastify" ;
107
118export interface FastifyHttpProxyOptions {
@@ -14,16 +11,8 @@ export interface FastifyHttpProxyOptions {
1411 rewritePrefix ?: string ;
1512 http2 ?: boolean ;
1613 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 ;
2716 config ?: Object ;
2817 replyOptions ?: Object ;
2918}
Original file line number Diff line number Diff line change 44 "description" : " proxy http requests, for Fastify" ,
55 "main" : " index.js" ,
66 "scripts" : {
7- "test" : " standard | snazzy && tap test/*.js" ,
7+ "test" : " standard | snazzy && tap test/*.js && npm run typescript " ,
88 "lint:typescript" : " standard --fix --parser @typescript-eslint/parser --plugin typescript test/types/*.ts" ,
99 "typescript" : " tsd"
1010 },
Original file line number Diff line number Diff line change 1- import fastify from "fastify" ;
1+ import fastify , { RawReplyDefaultExpression , RawRequestDefaultExpression } from "fastify" ;
22import fastifyHttpProxy from ".." ;
33import { expectType } from "tsd" ;
4- import { IncomingMessage , ServerResponse } from "http" ;
5- import { Http2ServerRequest , Http2ServerResponse } from "http2" ;
64
75const app = fastify ( ) ;
86
@@ -18,11 +16,11 @@ app.register(fastifyHttpProxy, {
1816 config : { key : 1 } ,
1917 replyOptions : { opt : "a" } ,
2018 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 ) ;
2321 } ,
2422 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 ) ;
2725 }
2826} ) ;
You can’t perform that action at this time.
0 commit comments