@@ -4,7 +4,7 @@ import { FastifySchemaCompiler, FastifySchemaValidationError } from './schema'
4
4
import { RawServerBase , RawRequestDefaultExpression , RawServerDefault , RawReplyDefaultExpression , ContextConfigDefault } from './utils'
5
5
import { FastifyLoggerInstance } from './logger'
6
6
import { FastifyRegister } from './register'
7
- import { onRequestHookHandler , preParsingHookHandler , onSendHookHandler , preValidationHookHandler , preHandlerHookHandler , preSerializationHookHandler , onResponseHookHandler , onErrorHookHandler , onRouteHookHandler , onRegisterHookHandler , onCloseHookHandler , onReadyHookHandler , onTimeoutHookHandler , preParsingAsyncHookHandler , preValidationAsyncHookHandler , preHandlerAsyncHookHandler , preSerializationAsyncHookHandler , onSendAsyncHookHandler , onResponseAsyncHookHandler , onTimeoutAsyncHookHandler , onErrorAsyncHookHandler , onReadyAsyncHookHandler } from './hooks'
7
+ import { onRequestHookHandler , preParsingHookHandler , onSendHookHandler , preValidationHookHandler , preHandlerHookHandler , preSerializationHookHandler , onResponseHookHandler , onErrorHookHandler , onRouteHookHandler , onRegisterHookHandler , onCloseHookHandler , onReadyHookHandler , onTimeoutHookHandler , preParsingAsyncHookHandler , preValidationAsyncHookHandler , preHandlerAsyncHookHandler , preSerializationAsyncHookHandler , onSendAsyncHookHandler , onResponseAsyncHookHandler , onTimeoutAsyncHookHandler , onErrorAsyncHookHandler , onReadyAsyncHookHandler , onRequestAsyncHookHandler } from './hooks'
8
8
import { FastifyRequest } from './request'
9
9
import { FastifyReply } from './reply'
10
10
import { FastifyError } from 'fastify-error'
@@ -89,6 +89,14 @@ export interface FastifyInstance<
89
89
hook : onRequestHookHandler < RawServer , RawRequest , RawReply , RouteGeneric , ContextConfig >
90
90
) : FastifyInstance < RawServer , RawRequest , RawReply , Logger > ;
91
91
92
+ addHook <
93
+ RouteGeneric extends RouteGenericInterface = RouteGenericInterface ,
94
+ ContextConfig = ContextConfigDefault
95
+ > (
96
+ name : 'onRequest' ,
97
+ hook : onRequestAsyncHookHandler < RawServer , RawRequest , RawReply , RouteGeneric , ContextConfig >
98
+ ) : FastifyInstance < RawServer , RawRequest , RawReply , Logger > ;
99
+
92
100
/**
93
101
* `preParsing` is the second hook to be executed in the request lifecycle. The previous hook was `onRequest`, the next hook will be `preValidation`.
94
102
* Notice: in the `preParsing` hook, request.body will always be null, because the body parsing happens before the `preHandler` hook.
0 commit comments