1
1
import { Readable } from 'stream'
2
- import { CallbackOrPromise } from './callback-or-promise'
3
2
import { FastifyInstance } from './instance'
4
3
import { RouteOptions , RouteGenericInterface } from './route'
5
4
import { RawServerBase , RawServerDefault , RawRequestDefaultExpression , RawReplyDefaultExpression , ContextConfigDefault } from './utils'
@@ -20,14 +19,23 @@ interface RequestPayload extends Readable {
20
19
* `onRequest` is the first hook to be executed in the request lifecycle. There was no previous hook, the next hook will be `preParsing`.
21
20
* Notice: in the `onRequest` hook, request.body will always be null, because the body parsing happens before the `preHandler` hook.
22
21
*/
23
- export type onRequestHookHandler <
22
+ export interface onRequestHookHandler <
24
23
RawServer extends RawServerBase = RawServerDefault ,
25
24
RawRequest extends RawRequestDefaultExpression < RawServer > = RawRequestDefaultExpression < RawServer > ,
26
25
RawReply extends RawReplyDefaultExpression < RawServer > = RawReplyDefaultExpression < RawServer > ,
27
26
RouteGeneric extends RouteGenericInterface = RouteGenericInterface ,
28
- ContextConfig = ContextConfigDefault ,
29
- T extends ( ...args : any [ ] ) => void = ( ...args : any [ ] ) => void
30
- > = CallbackOrPromise < T , [ FastifyRequest < RouteGeneric , RawServer , RawRequest > , FastifyReply < RawServer , RawRequest , RawReply , RouteGeneric , ContextConfig > ] , HookHandlerDoneFunction >
27
+ ContextConfig = ContextConfigDefault
28
+ > {
29
+ (
30
+ request : FastifyRequest < RouteGeneric , RawServer , RawRequest > ,
31
+ reply : FastifyReply < RawServer , RawRequest , RawReply , RouteGeneric , ContextConfig > ,
32
+ done : HookHandlerDoneFunction
33
+ ) : void ;
34
+ (
35
+ request : FastifyRequest < RouteGeneric , RawServer , RawRequest > ,
36
+ reply : FastifyReply < RawServer , RawRequest , RawReply , RouteGeneric , ContextConfig > ,
37
+ ) : Promise < unknown > ;
38
+ }
31
39
32
40
/**
33
41
* `preParsing` is the second hook to be executed in the request lifecycle. The previous hook was `onRequest`, the next hook will be `preValidation`.
0 commit comments