fastify 3.26.0 → 4.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +5 -4
  2. package/build/build-error-serializer.js +27 -0
  3. package/build/build-validation.js +49 -35
  4. package/docs/Guides/Ecosystem.md +2 -1
  5. package/docs/Guides/Prototype-Poisoning.md +3 -3
  6. package/docs/Migration-Guide-V4.md +12 -0
  7. package/docs/Reference/ContentTypeParser.md +8 -1
  8. package/docs/Reference/Errors.md +51 -6
  9. package/docs/Reference/Hooks.md +4 -7
  10. package/docs/Reference/LTS.md +5 -4
  11. package/docs/Reference/Reply.md +23 -22
  12. package/docs/Reference/Request.md +1 -3
  13. package/docs/Reference/Routes.md +17 -10
  14. package/docs/Reference/Server.md +98 -63
  15. package/docs/Reference/TypeScript.md +11 -13
  16. package/docs/Reference/Validation-and-Serialization.md +32 -54
  17. package/docs/Type-Providers.md +257 -0
  18. package/examples/hooks.js +1 -1
  19. package/examples/simple-stream.js +18 -0
  20. package/fastify.d.ts +36 -22
  21. package/fastify.js +72 -53
  22. package/lib/configValidator.js +902 -1023
  23. package/lib/contentTypeParser.js +6 -16
  24. package/lib/context.js +36 -10
  25. package/lib/decorate.js +5 -3
  26. package/lib/error-handler.js +158 -0
  27. package/lib/error-serializer.js +257 -0
  28. package/lib/errors.js +49 -10
  29. package/lib/fourOhFour.js +31 -20
  30. package/lib/handleRequest.js +10 -13
  31. package/lib/hooks.js +14 -9
  32. package/lib/noop-set.js +10 -0
  33. package/lib/pluginOverride.js +0 -3
  34. package/lib/pluginUtils.js +3 -2
  35. package/lib/reply.js +44 -163
  36. package/lib/request.js +13 -10
  37. package/lib/route.js +158 -139
  38. package/lib/schema-controller.js +3 -3
  39. package/lib/schemas.js +27 -1
  40. package/lib/server.js +219 -116
  41. package/lib/symbols.js +6 -4
  42. package/lib/validation.js +2 -1
  43. package/lib/warnings.js +2 -12
  44. package/lib/wrapThenable.js +4 -11
  45. package/package.json +40 -45
  46. package/test/404s.test.js +265 -108
  47. package/test/500s.test.js +2 -2
  48. package/test/async-await.test.js +15 -71
  49. package/test/close.test.js +39 -1
  50. package/test/content-parser.test.js +32 -0
  51. package/test/context-config.test.js +56 -4
  52. package/test/custom-http-server.test.js +14 -7
  53. package/test/custom-parser-async.test.js +0 -65
  54. package/test/custom-parser.test.js +54 -121
  55. package/test/decorator.test.js +1 -3
  56. package/test/delete.test.js +5 -5
  57. package/test/encapsulated-error-handler.test.js +50 -0
  58. package/test/esm/index.test.js +0 -14
  59. package/test/fastify-instance.test.js +4 -4
  60. package/test/fluent-schema.test.js +4 -4
  61. package/test/get.test.js +3 -3
  62. package/test/helper.js +18 -3
  63. package/test/hooks-async.test.js +14 -47
  64. package/test/hooks.on-ready.test.js +9 -4
  65. package/test/hooks.test.js +58 -99
  66. package/test/http2/closing.test.js +5 -11
  67. package/test/http2/unknown-http-method.test.js +3 -9
  68. package/test/https/custom-https-server.test.js +12 -6
  69. package/test/inject.test.js +1 -1
  70. package/test/input-validation.js +2 -2
  71. package/test/internals/all.test.js +2 -2
  72. package/test/internals/contentTypeParser.test.js +4 -4
  73. package/test/internals/handleRequest.test.js +9 -46
  74. package/test/internals/initialConfig.test.js +33 -12
  75. package/test/internals/logger.test.js +1 -1
  76. package/test/internals/reply.test.js +245 -3
  77. package/test/internals/request.test.js +13 -7
  78. package/test/internals/server.test.js +88 -0
  79. package/test/listen.test.js +84 -1
  80. package/test/logger.test.js +98 -58
  81. package/test/maxRequestsPerSocket.test.js +8 -6
  82. package/test/middleware.test.js +2 -25
  83. package/test/noop-set.test.js +19 -0
  84. package/test/nullable-validation.test.js +51 -14
  85. package/test/plugin.test.js +31 -5
  86. package/test/pretty-print.test.js +22 -10
  87. package/test/reply-error.test.js +123 -12
  88. package/test/request-error.test.js +2 -5
  89. package/test/route-hooks.test.js +17 -17
  90. package/test/route-prefix.test.js +2 -1
  91. package/test/route.test.js +216 -20
  92. package/test/router-options.test.js +1 -1
  93. package/test/schema-examples.test.js +11 -5
  94. package/test/schema-feature.test.js +24 -19
  95. package/test/schema-serialization.test.js +50 -9
  96. package/test/schema-special-usage.test.js +14 -81
  97. package/test/schema-validation.test.js +9 -9
  98. package/test/skip-reply-send.test.js +8 -8
  99. package/test/stream.test.js +23 -12
  100. package/test/throw.test.js +8 -5
  101. package/test/trust-proxy.test.js +1 -1
  102. package/test/type-provider.test.js +20 -0
  103. package/test/types/fastify.test-d.ts +12 -18
  104. package/test/types/hooks.test-d.ts +7 -3
  105. package/test/types/import.js +2 -0
  106. package/test/types/import.ts +1 -0
  107. package/test/types/instance.test-d.ts +61 -15
  108. package/test/types/logger.test-d.ts +44 -15
  109. package/test/types/route.test-d.ts +8 -2
  110. package/test/types/schema.test-d.ts +2 -39
  111. package/test/types/type-provider.test-d.ts +417 -0
  112. package/test/validation-error-handling.test.js +9 -9
  113. package/test/versioned-routes.test.js +29 -17
  114. package/test/wrapThenable.test.js +7 -6
  115. package/types/.eslintrc.json +1 -1
  116. package/types/content-type-parser.d.ts +17 -8
  117. package/types/hooks.d.ts +107 -60
  118. package/types/instance.d.ts +137 -105
  119. package/types/logger.d.ts +18 -104
  120. package/types/plugin.d.ts +10 -4
  121. package/types/register.d.ts +1 -1
  122. package/types/reply.d.ts +16 -11
  123. package/types/request.d.ts +10 -5
  124. package/types/route.d.ts +42 -31
  125. package/types/schema.d.ts +15 -1
  126. package/types/type-provider.d.ts +99 -0
  127. package/types/utils.d.ts +1 -1
  128. package/lib/schema-compilers.js +0 -12
  129. package/test/emit-warning.test.js +0 -166
package/types/hooks.d.ts CHANGED
@@ -6,6 +6,10 @@ import { FastifyRequest } from './request'
6
6
  import { FastifyReply } from './reply'
7
7
  import { FastifyError } from 'fastify-error'
8
8
  import { FastifyLoggerInstance } from './logger'
9
+ import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
10
+ import { RegisterOptions } from './register'
11
+ import { FastifySchema } from './schema'
12
+ import { FastifyPluginOptions } from './plugin'
9
13
 
10
14
  type HookHandlerDoneFunction = <TError extends Error = FastifyError>(err?: TError) => void
11
15
 
@@ -24,12 +28,15 @@ export interface onRequestHookHandler<
24
28
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
25
29
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
26
30
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
27
- ContextConfig = ContextConfigDefault
31
+ ContextConfig = ContextConfigDefault,
32
+ SchemaCompiler extends FastifySchema = FastifySchema,
33
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
34
+
28
35
  > {
29
36
  (
30
37
  this: FastifyInstance,
31
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
32
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
38
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
39
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
33
40
  done: HookHandlerDoneFunction
34
41
  ): void;
35
42
  }
@@ -39,12 +46,14 @@ export interface onRequestAsyncHookHandler<
39
46
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
40
47
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
41
48
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
42
- ContextConfig = ContextConfigDefault
49
+ ContextConfig = ContextConfigDefault,
50
+ SchemaCompiler extends FastifySchema = FastifySchema,
51
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
43
52
  > {
44
53
  (
45
54
  this: FastifyInstance,
46
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
47
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
55
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
56
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
48
57
  ): Promise<unknown>;
49
58
  }
50
59
 
@@ -57,12 +66,14 @@ export interface preParsingHookHandler<
57
66
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
58
67
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
59
68
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
60
- ContextConfig = ContextConfigDefault
69
+ ContextConfig = ContextConfigDefault,
70
+ SchemaCompiler extends FastifySchema = FastifySchema,
71
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
61
72
  > {
62
73
  (
63
74
  this: FastifyInstance,
64
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
65
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
75
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
76
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
66
77
  payload: RequestPayload,
67
78
  done: <TError extends Error = FastifyError>(err?: TError | null, res?: RequestPayload) => void
68
79
  ): void;
@@ -73,12 +84,14 @@ export interface preParsingAsyncHookHandler<
73
84
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
74
85
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
75
86
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
76
- ContextConfig = ContextConfigDefault
87
+ ContextConfig = ContextConfigDefault,
88
+ SchemaCompiler extends FastifySchema = FastifySchema,
89
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
77
90
  > {
78
91
  (
79
92
  this: FastifyInstance,
80
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
81
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
93
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
94
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
82
95
  payload: RequestPayload,
83
96
  ): Promise<RequestPayload | unknown>;
84
97
  }
@@ -91,12 +104,14 @@ export interface preValidationHookHandler<
91
104
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
92
105
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
93
106
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
94
- ContextConfig = ContextConfigDefault
107
+ ContextConfig = ContextConfigDefault,
108
+ SchemaCompiler extends FastifySchema = FastifySchema,
109
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
95
110
  > {
96
111
  (
97
112
  this: FastifyInstance,
98
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
99
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
113
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
114
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
100
115
  done: HookHandlerDoneFunction
101
116
  ): void;
102
117
  }
@@ -106,12 +121,14 @@ export interface preValidationAsyncHookHandler<
106
121
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
107
122
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
108
123
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
109
- ContextConfig = ContextConfigDefault
124
+ ContextConfig = ContextConfigDefault,
125
+ SchemaCompiler extends FastifySchema = FastifySchema,
126
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
110
127
  > {
111
128
  (
112
129
  this: FastifyInstance,
113
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
114
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
130
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
131
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
115
132
  ): Promise<unknown>;
116
133
  }
117
134
 
@@ -123,12 +140,14 @@ export interface preHandlerHookHandler<
123
140
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
124
141
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
125
142
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
126
- ContextConfig = ContextConfigDefault
143
+ ContextConfig = ContextConfigDefault,
144
+ SchemaCompiler extends FastifySchema = FastifySchema,
145
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
127
146
  > {
128
147
  (
129
148
  this: FastifyInstance,
130
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
131
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
149
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
150
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
132
151
  done: HookHandlerDoneFunction
133
152
  ): void;
134
153
  }
@@ -138,12 +157,14 @@ export interface preHandlerAsyncHookHandler<
138
157
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
139
158
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
140
159
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
141
- ContextConfig = ContextConfigDefault
160
+ ContextConfig = ContextConfigDefault,
161
+ SchemaCompiler extends FastifySchema = FastifySchema,
162
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
142
163
  > {
143
164
  (
144
165
  this: FastifyInstance,
145
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
146
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
166
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
167
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
147
168
  ): Promise<unknown>;
148
169
  }
149
170
 
@@ -164,12 +185,14 @@ export interface preSerializationHookHandler<
164
185
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
165
186
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
166
187
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
167
- ContextConfig = ContextConfigDefault
188
+ ContextConfig = ContextConfigDefault,
189
+ SchemaCompiler extends FastifySchema = FastifySchema,
190
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
168
191
  > {
169
192
  (
170
193
  this: FastifyInstance,
171
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
172
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
194
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
195
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
173
196
  payload: PreSerializationPayload,
174
197
  done: DoneFuncWithErrOrRes
175
198
  ): void;
@@ -181,12 +204,14 @@ export interface preSerializationAsyncHookHandler<
181
204
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
182
205
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
183
206
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
184
- ContextConfig = ContextConfigDefault
207
+ ContextConfig = ContextConfigDefault,
208
+ SchemaCompiler extends FastifySchema = FastifySchema,
209
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
185
210
  > {
186
211
  (
187
212
  this: FastifyInstance,
188
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
189
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
213
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
214
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
190
215
  payload: PreSerializationPayload
191
216
  ): Promise<unknown>;
192
217
  }
@@ -201,12 +226,14 @@ export interface onSendHookHandler<
201
226
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
202
227
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
203
228
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
204
- ContextConfig = ContextConfigDefault
229
+ ContextConfig = ContextConfigDefault,
230
+ SchemaCompiler extends FastifySchema = FastifySchema,
231
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
205
232
  > {
206
233
  (
207
234
  this: FastifyInstance,
208
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
209
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
235
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
236
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
210
237
  payload: OnSendPayload,
211
238
  done: DoneFuncWithErrOrRes
212
239
  ): void;
@@ -218,12 +245,14 @@ export interface onSendAsyncHookHandler<
218
245
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
219
246
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
220
247
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
221
- ContextConfig = ContextConfigDefault
248
+ ContextConfig = ContextConfigDefault,
249
+ SchemaCompiler extends FastifySchema = FastifySchema,
250
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
222
251
  > {
223
252
  (
224
253
  this: FastifyInstance,
225
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
226
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
254
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
255
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
227
256
  payload: OnSendPayload,
228
257
  ): Promise<unknown>;
229
258
  }
@@ -237,12 +266,14 @@ export interface onResponseHookHandler<
237
266
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
238
267
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
239
268
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
240
- ContextConfig = ContextConfigDefault
269
+ ContextConfig = ContextConfigDefault,
270
+ SchemaCompiler extends FastifySchema = FastifySchema,
271
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
241
272
  > {
242
273
  (
243
274
  this: FastifyInstance,
244
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
245
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
275
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
276
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
246
277
  done: HookHandlerDoneFunction
247
278
  ): void;
248
279
  }
@@ -252,12 +283,14 @@ export interface onResponseAsyncHookHandler<
252
283
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
253
284
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
254
285
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
255
- ContextConfig = ContextConfigDefault
286
+ ContextConfig = ContextConfigDefault,
287
+ SchemaCompiler extends FastifySchema = FastifySchema,
288
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
256
289
  > {
257
290
  (
258
291
  this: FastifyInstance,
259
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
260
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
292
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
293
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
261
294
  ): Promise<unknown>;
262
295
  }
263
296
 
@@ -270,12 +303,14 @@ export interface onTimeoutHookHandler<
270
303
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
271
304
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
272
305
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
273
- ContextConfig = ContextConfigDefault
306
+ ContextConfig = ContextConfigDefault,
307
+ SchemaCompiler extends FastifySchema = FastifySchema,
308
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
274
309
  > {
275
310
  (
276
311
  this: FastifyInstance,
277
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
278
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
312
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
313
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
279
314
  done: HookHandlerDoneFunction
280
315
  ): void;
281
316
  }
@@ -285,12 +320,14 @@ export interface onTimeoutAsyncHookHandler<
285
320
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
286
321
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
287
322
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
288
- ContextConfig = ContextConfigDefault
323
+ ContextConfig = ContextConfigDefault,
324
+ SchemaCompiler extends FastifySchema = FastifySchema,
325
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
289
326
  > {
290
327
  (
291
328
  this: FastifyInstance,
292
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
293
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
329
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
330
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
294
331
  ): Promise<unknown>;
295
332
  }
296
333
 
@@ -306,12 +343,14 @@ export interface onErrorHookHandler<
306
343
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
307
344
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
308
345
  ContextConfig = ContextConfigDefault,
309
- TError extends Error = FastifyError
346
+ TError extends Error = FastifyError,
347
+ SchemaCompiler extends FastifySchema = FastifySchema,
348
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
310
349
  > {
311
350
  (
312
351
  this: FastifyInstance,
313
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
314
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
352
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
353
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
315
354
  error: TError,
316
355
  done: () => void
317
356
  ): void;
@@ -323,12 +362,14 @@ export interface onErrorAsyncHookHandler<
323
362
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
324
363
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
325
364
  ContextConfig = ContextConfigDefault,
326
- TError extends Error = FastifyError
365
+ TError extends Error = FastifyError,
366
+ SchemaCompiler extends FastifySchema = FastifySchema,
367
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
327
368
  > {
328
369
  (
329
370
  this: FastifyInstance,
330
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
331
- reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>,
371
+ request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>,
372
+ reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
332
373
  error: TError
333
374
  ): Promise<unknown>;
334
375
  }
@@ -343,11 +384,13 @@ export interface onRouteHookHandler<
343
384
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
344
385
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
345
386
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
346
- ContextConfig = ContextConfigDefault
387
+ ContextConfig = ContextConfigDefault,
388
+ SchemaCompiler extends FastifySchema = FastifySchema,
389
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
347
390
  > {
348
391
  (
349
392
  this: FastifyInstance,
350
- opts: RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig> & { routePath: string; path: string; prefix: string }
393
+ opts: RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider> & { routePath: string; path: string; prefix: string }
351
394
  ): Promise<unknown> | void;
352
395
  }
353
396
 
@@ -360,10 +403,13 @@ export interface onRegisterHookHandler<
360
403
  RawServer extends RawServerBase = RawServerDefault,
361
404
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
362
405
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
363
- Logger = FastifyLoggerInstance
406
+ Logger = FastifyLoggerInstance,
407
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
408
+ Options extends FastifyPluginOptions = FastifyPluginOptions
364
409
  > {
365
410
  (
366
- instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger>,
411
+ instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
412
+ opts: RegisterOptions & Options,
367
413
  done: HookHandlerDoneFunction
368
414
  ): Promise<unknown> | void; // documentation is missing the `done` method
369
415
  }
@@ -390,10 +436,11 @@ export interface onCloseHookHandler<
390
436
  RawServer extends RawServerBase = RawServerDefault,
391
437
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
392
438
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
393
- Logger = FastifyLoggerInstance
439
+ Logger = FastifyLoggerInstance,
440
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
394
441
  > {
395
442
  (
396
- instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger>,
443
+ instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
397
444
  done: HookHandlerDoneFunction
398
445
  ): void;
399
446
  }