fastify 3.27.3 → 4.0.0-alpha.2

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 (164) hide show
  1. package/.taprc +3 -0
  2. package/README.md +7 -7
  3. package/build/build-error-serializer.js +27 -0
  4. package/build/build-validation.js +47 -35
  5. package/docs/Guides/Database.md +320 -0
  6. package/docs/Guides/Getting-Started.md +7 -7
  7. package/docs/Guides/Plugins-Guide.md +1 -1
  8. package/docs/Guides/Serverless.md +3 -3
  9. package/docs/Guides/Testing.md +2 -2
  10. package/docs/Migration-Guide-V4.md +12 -0
  11. package/docs/Reference/ContentTypeParser.md +4 -0
  12. package/docs/Reference/Decorators.md +2 -2
  13. package/docs/Reference/Encapsulation.md +2 -2
  14. package/docs/Reference/Errors.md +51 -6
  15. package/docs/Reference/HTTP2.md +3 -3
  16. package/docs/Reference/Hooks.md +4 -7
  17. package/docs/Reference/LTS.md +5 -4
  18. package/docs/Reference/Plugins.md +3 -3
  19. package/docs/Reference/Reply.md +23 -22
  20. package/docs/Reference/Request.md +1 -3
  21. package/docs/Reference/Routes.md +22 -15
  22. package/docs/Reference/Server.md +69 -119
  23. package/docs/Reference/TypeScript.md +20 -22
  24. package/docs/Reference/Validation-and-Serialization.md +30 -55
  25. package/docs/Type-Providers.md +257 -0
  26. package/examples/asyncawait.js +1 -1
  27. package/examples/benchmark/hooks-benchmark-async-await.js +1 -1
  28. package/examples/benchmark/hooks-benchmark.js +1 -1
  29. package/examples/benchmark/simple.js +1 -1
  30. package/examples/hooks.js +2 -2
  31. package/examples/http2.js +1 -1
  32. package/examples/https.js +1 -1
  33. package/examples/parser.js +1 -1
  34. package/examples/route-prefix.js +1 -1
  35. package/examples/shared-schema.js +1 -1
  36. package/examples/simple-stream.js +18 -0
  37. package/examples/simple.js +1 -1
  38. package/examples/simple.mjs +1 -1
  39. package/examples/typescript-server.ts +1 -1
  40. package/examples/use-plugin.js +1 -1
  41. package/fastify.d.ts +34 -22
  42. package/fastify.js +40 -36
  43. package/lib/configValidator.js +902 -1023
  44. package/lib/contentTypeParser.js +6 -16
  45. package/lib/context.js +36 -10
  46. package/lib/decorate.js +3 -1
  47. package/lib/error-handler.js +158 -0
  48. package/lib/error-serializer.js +257 -0
  49. package/lib/errors.js +43 -9
  50. package/lib/fourOhFour.js +31 -20
  51. package/lib/handleRequest.js +10 -13
  52. package/lib/hooks.js +14 -9
  53. package/lib/pluginOverride.js +0 -3
  54. package/lib/pluginUtils.js +3 -2
  55. package/lib/reply.js +29 -158
  56. package/lib/request.js +13 -10
  57. package/lib/route.js +131 -138
  58. package/lib/schema-controller.js +2 -2
  59. package/lib/schemas.js +27 -1
  60. package/lib/server.js +241 -116
  61. package/lib/symbols.js +4 -3
  62. package/lib/validation.js +2 -1
  63. package/lib/warnings.js +4 -12
  64. package/lib/wrapThenable.js +4 -11
  65. package/package.json +37 -39
  66. package/test/404s.test.js +258 -125
  67. package/test/500s.test.js +3 -3
  68. package/test/als.test.js +1 -1
  69. package/test/async-await.test.js +20 -76
  70. package/test/bodyLimit.test.js +1 -1
  71. package/test/build-certificate.js +6 -7
  72. package/test/case-insensitive.test.js +4 -4
  73. package/test/close-pipelining.test.js +2 -2
  74. package/test/close.test.js +11 -11
  75. package/test/content-parser.test.js +32 -0
  76. package/test/context-config.test.js +52 -0
  77. package/test/custom-http-server.test.js +14 -7
  78. package/test/custom-parser-async.test.js +1 -66
  79. package/test/custom-parser.test.js +92 -159
  80. package/test/custom-querystring-parser.test.js +3 -3
  81. package/test/decorator.test.js +11 -13
  82. package/test/delete.test.js +6 -6
  83. package/test/encapsulated-error-handler.test.js +50 -0
  84. package/test/esm/index.test.js +0 -14
  85. package/test/fastify-instance.test.js +4 -4
  86. package/test/fluent-schema.test.js +4 -4
  87. package/test/genReqId.test.js +1 -1
  88. package/test/get.test.js +4 -4
  89. package/test/handler-context.test.js +2 -2
  90. package/test/head.test.js +1 -1
  91. package/test/helper.js +19 -4
  92. package/test/hooks-async.test.js +15 -48
  93. package/test/hooks.on-ready.test.js +10 -5
  94. package/test/hooks.test.js +78 -119
  95. package/test/http2/closing.test.js +10 -16
  96. package/test/http2/constraint.test.js +1 -1
  97. package/test/http2/head.test.js +1 -1
  98. package/test/http2/plain.test.js +1 -1
  99. package/test/http2/secure-with-fallback.test.js +1 -1
  100. package/test/http2/secure.test.js +1 -1
  101. package/test/http2/unknown-http-method.test.js +4 -10
  102. package/test/https/custom-https-server.test.js +12 -6
  103. package/test/https/https.test.js +1 -1
  104. package/test/input-validation.js +3 -3
  105. package/test/internals/handleRequest.test.js +6 -43
  106. package/test/internals/initialConfig.test.js +41 -12
  107. package/test/internals/logger.test.js +2 -2
  108. package/test/internals/reply.test.js +281 -40
  109. package/test/internals/request.test.js +13 -7
  110. package/test/internals/server.test.js +88 -0
  111. package/test/listen.deprecated.test.js +202 -0
  112. package/test/listen.test.js +118 -150
  113. package/test/logger.test.js +82 -42
  114. package/test/maxRequestsPerSocket.test.js +8 -6
  115. package/test/middleware.test.js +2 -25
  116. package/test/nullable-validation.test.js +53 -16
  117. package/test/output-validation.test.js +1 -1
  118. package/test/plugin.test.js +47 -21
  119. package/test/pretty-print.test.js +22 -10
  120. package/test/promises.test.js +1 -1
  121. package/test/proto-poisoning.test.js +6 -6
  122. package/test/register.test.js +3 -3
  123. package/test/reply-error.test.js +126 -15
  124. package/test/request-error.test.js +3 -6
  125. package/test/route-hooks.test.js +18 -18
  126. package/test/route-prefix.test.js +2 -1
  127. package/test/route.test.js +206 -22
  128. package/test/router-options.test.js +2 -2
  129. package/test/schema-examples.test.js +11 -5
  130. package/test/schema-feature.test.js +25 -20
  131. package/test/schema-serialization.test.js +9 -9
  132. package/test/schema-special-usage.test.js +5 -153
  133. package/test/schema-validation.test.js +9 -9
  134. package/test/skip-reply-send.test.js +2 -2
  135. package/test/stream.test.js +82 -23
  136. package/test/throw.test.js +8 -5
  137. package/test/trust-proxy.test.js +6 -6
  138. package/test/type-provider.test.js +20 -0
  139. package/test/types/fastify.test-d.ts +10 -18
  140. package/test/types/import.js +2 -0
  141. package/test/types/import.ts +1 -0
  142. package/test/types/instance.test-d.ts +68 -17
  143. package/test/types/logger.test-d.ts +44 -15
  144. package/test/types/reply.test-d.ts +2 -1
  145. package/test/types/route.test-d.ts +8 -2
  146. package/test/types/schema.test-d.ts +2 -39
  147. package/test/types/type-provider.test-d.ts +417 -0
  148. package/test/url-rewriting.test.js +3 -3
  149. package/test/validation-error-handling.test.js +8 -8
  150. package/test/versioned-routes.test.js +30 -18
  151. package/test/wrapThenable.test.js +7 -6
  152. package/types/content-type-parser.d.ts +17 -8
  153. package/types/hooks.d.ts +102 -59
  154. package/types/instance.d.ts +244 -118
  155. package/types/logger.d.ts +18 -104
  156. package/types/plugin.d.ts +10 -4
  157. package/types/reply.d.ts +18 -12
  158. package/types/request.d.ts +10 -5
  159. package/types/route.d.ts +42 -31
  160. package/types/schema.d.ts +1 -1
  161. package/types/type-provider.d.ts +99 -0
  162. package/types/utils.d.ts +1 -1
  163. package/lib/schema-compilers.js +0 -12
  164. package/test/emit-warning.test.js +0 -166
@@ -1,6 +1,8 @@
1
1
  import { RawServerBase, RawServerDefault, RawRequestDefaultExpression } from './utils'
2
2
  import { FastifyRequest } from './request'
3
3
  import { RouteGenericInterface } from './route'
4
+ import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
5
+ import { FastifySchema } from './schema'
4
6
 
5
7
  type ContentTypeParserDoneFunction = (err: Error | null, body?: any) => void
6
8
 
@@ -12,8 +14,10 @@ export type FastifyBodyParser<
12
14
  RawServer extends RawServerBase = RawServerDefault,
13
15
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
14
16
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
15
- > = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, rawBody: RawBody, done: ContentTypeParserDoneFunction) => void)
16
- | ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, rawBody: RawBody) => Promise<any>)
17
+ SchemaCompiler extends FastifySchema = FastifySchema,
18
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
19
+ > = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, rawBody: RawBody, done: ContentTypeParserDoneFunction) => void)
20
+ | ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, rawBody: RawBody) => Promise<any>)
17
21
 
18
22
  /**
19
23
  * Content Type Parser method that operates on request content
@@ -22,31 +26,36 @@ export type FastifyContentTypeParser<
22
26
  RawServer extends RawServerBase = RawServerDefault,
23
27
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
24
28
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
25
- > = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, payload: RawRequest) => Promise<any>)
26
- | ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, payload: RawRequest, done: ContentTypeParserDoneFunction) => void)
29
+ SchemaCompiler extends FastifySchema = FastifySchema,
30
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
31
+ > = ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, payload: RawRequest) => Promise<any>)
32
+ | ((request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, payload: RawRequest, done: ContentTypeParserDoneFunction) => void)
27
33
 
28
34
  /**
29
35
  * Natively, Fastify only supports 'application/json' and 'text/plain' content types. The default charset is utf-8. If you need to support different content types, you can use the addContentTypeParser API. The default JSON and/or plain text parser can be changed.
30
36
  */
31
37
  export interface AddContentTypeParser<
32
38
  RawServer extends RawServerBase = RawServerDefault,
33
- RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>
39
+ RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
40
+ RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
41
+ SchemaCompiler extends FastifySchema = FastifySchema,
42
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
34
43
  > {
35
44
  (
36
45
  contentType: string | string[] | RegExp,
37
46
  opts: {
38
47
  bodyLimit?: number;
39
48
  },
40
- parser: FastifyContentTypeParser<RawServer, RawRequest>
49
+ parser: FastifyContentTypeParser<RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>
41
50
  ): void;
42
- (contentType: string | string[] | RegExp, parser: FastifyContentTypeParser<RawServer, RawRequest>): void;
51
+ (contentType: string | string[] | RegExp, parser: FastifyContentTypeParser<RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>): void;
43
52
  <parseAs extends string | Buffer>(
44
53
  contentType: string | string[] | RegExp,
45
54
  opts: {
46
55
  parseAs: parseAs extends Buffer ? 'buffer' : 'string';
47
56
  bodyLimit?: number;
48
57
  },
49
- parser: FastifyBodyParser<parseAs, RawServer, RawRequest>
58
+ parser: FastifyBodyParser<parseAs, RawServer, RawRequest, RouteGeneric, SchemaCompiler, TypeProvider>
50
59
  ): void;
51
60
  }
52
61
 
package/types/hooks.d.ts CHANGED
@@ -6,7 +6,9 @@ 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'
9
10
  import { RegisterOptions } from './register'
11
+ import { FastifySchema } from './schema'
10
12
  import { FastifyPluginOptions } from './plugin'
11
13
 
12
14
  type HookHandlerDoneFunction = <TError extends Error = FastifyError>(err?: TError) => void
@@ -26,12 +28,15 @@ export interface onRequestHookHandler<
26
28
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
27
29
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
28
30
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
29
- ContextConfig = ContextConfigDefault
31
+ ContextConfig = ContextConfigDefault,
32
+ SchemaCompiler extends FastifySchema = FastifySchema,
33
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
34
+
30
35
  > {
31
36
  (
32
37
  this: FastifyInstance,
33
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
34
- 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>,
35
40
  done: HookHandlerDoneFunction
36
41
  ): void;
37
42
  }
@@ -41,12 +46,14 @@ export interface onRequestAsyncHookHandler<
41
46
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
42
47
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
43
48
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
44
- ContextConfig = ContextConfigDefault
49
+ ContextConfig = ContextConfigDefault,
50
+ SchemaCompiler extends FastifySchema = FastifySchema,
51
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
45
52
  > {
46
53
  (
47
54
  this: FastifyInstance,
48
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
49
- 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>,
50
57
  ): Promise<unknown>;
51
58
  }
52
59
 
@@ -59,12 +66,14 @@ export interface preParsingHookHandler<
59
66
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
60
67
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
61
68
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
62
- ContextConfig = ContextConfigDefault
69
+ ContextConfig = ContextConfigDefault,
70
+ SchemaCompiler extends FastifySchema = FastifySchema,
71
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
63
72
  > {
64
73
  (
65
74
  this: FastifyInstance,
66
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
67
- 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>,
68
77
  payload: RequestPayload,
69
78
  done: <TError extends Error = FastifyError>(err?: TError | null, res?: RequestPayload) => void
70
79
  ): void;
@@ -75,12 +84,14 @@ export interface preParsingAsyncHookHandler<
75
84
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
76
85
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
77
86
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
78
- ContextConfig = ContextConfigDefault
87
+ ContextConfig = ContextConfigDefault,
88
+ SchemaCompiler extends FastifySchema = FastifySchema,
89
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
79
90
  > {
80
91
  (
81
92
  this: FastifyInstance,
82
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
83
- 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>,
84
95
  payload: RequestPayload,
85
96
  ): Promise<RequestPayload | unknown>;
86
97
  }
@@ -93,12 +104,14 @@ export interface preValidationHookHandler<
93
104
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
94
105
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
95
106
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
96
- ContextConfig = ContextConfigDefault
107
+ ContextConfig = ContextConfigDefault,
108
+ SchemaCompiler extends FastifySchema = FastifySchema,
109
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
97
110
  > {
98
111
  (
99
112
  this: FastifyInstance,
100
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
101
- 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>,
102
115
  done: HookHandlerDoneFunction
103
116
  ): void;
104
117
  }
@@ -108,12 +121,14 @@ export interface preValidationAsyncHookHandler<
108
121
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
109
122
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
110
123
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
111
- ContextConfig = ContextConfigDefault
124
+ ContextConfig = ContextConfigDefault,
125
+ SchemaCompiler extends FastifySchema = FastifySchema,
126
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
112
127
  > {
113
128
  (
114
129
  this: FastifyInstance,
115
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
116
- 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>,
117
132
  ): Promise<unknown>;
118
133
  }
119
134
 
@@ -125,12 +140,14 @@ export interface preHandlerHookHandler<
125
140
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
126
141
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
127
142
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
128
- ContextConfig = ContextConfigDefault
143
+ ContextConfig = ContextConfigDefault,
144
+ SchemaCompiler extends FastifySchema = FastifySchema,
145
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
129
146
  > {
130
147
  (
131
148
  this: FastifyInstance,
132
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
133
- 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>,
134
151
  done: HookHandlerDoneFunction
135
152
  ): void;
136
153
  }
@@ -140,12 +157,14 @@ export interface preHandlerAsyncHookHandler<
140
157
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
141
158
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
142
159
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
143
- ContextConfig = ContextConfigDefault
160
+ ContextConfig = ContextConfigDefault,
161
+ SchemaCompiler extends FastifySchema = FastifySchema,
162
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
144
163
  > {
145
164
  (
146
165
  this: FastifyInstance,
147
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
148
- 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>,
149
168
  ): Promise<unknown>;
150
169
  }
151
170
 
@@ -166,12 +185,14 @@ export interface preSerializationHookHandler<
166
185
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
167
186
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
168
187
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
169
- ContextConfig = ContextConfigDefault
188
+ ContextConfig = ContextConfigDefault,
189
+ SchemaCompiler extends FastifySchema = FastifySchema,
190
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
170
191
  > {
171
192
  (
172
193
  this: FastifyInstance,
173
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
174
- 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>,
175
196
  payload: PreSerializationPayload,
176
197
  done: DoneFuncWithErrOrRes
177
198
  ): void;
@@ -183,12 +204,14 @@ export interface preSerializationAsyncHookHandler<
183
204
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
184
205
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
185
206
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
186
- ContextConfig = ContextConfigDefault
207
+ ContextConfig = ContextConfigDefault,
208
+ SchemaCompiler extends FastifySchema = FastifySchema,
209
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
187
210
  > {
188
211
  (
189
212
  this: FastifyInstance,
190
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
191
- 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>,
192
215
  payload: PreSerializationPayload
193
216
  ): Promise<unknown>;
194
217
  }
@@ -203,12 +226,14 @@ export interface onSendHookHandler<
203
226
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
204
227
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
205
228
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
206
- ContextConfig = ContextConfigDefault
229
+ ContextConfig = ContextConfigDefault,
230
+ SchemaCompiler extends FastifySchema = FastifySchema,
231
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
207
232
  > {
208
233
  (
209
234
  this: FastifyInstance,
210
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
211
- 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>,
212
237
  payload: OnSendPayload,
213
238
  done: DoneFuncWithErrOrRes
214
239
  ): void;
@@ -220,12 +245,14 @@ export interface onSendAsyncHookHandler<
220
245
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
221
246
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
222
247
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
223
- ContextConfig = ContextConfigDefault
248
+ ContextConfig = ContextConfigDefault,
249
+ SchemaCompiler extends FastifySchema = FastifySchema,
250
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
224
251
  > {
225
252
  (
226
253
  this: FastifyInstance,
227
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
228
- 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>,
229
256
  payload: OnSendPayload,
230
257
  ): Promise<unknown>;
231
258
  }
@@ -239,12 +266,14 @@ export interface onResponseHookHandler<
239
266
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
240
267
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
241
268
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
242
- ContextConfig = ContextConfigDefault
269
+ ContextConfig = ContextConfigDefault,
270
+ SchemaCompiler extends FastifySchema = FastifySchema,
271
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
243
272
  > {
244
273
  (
245
274
  this: FastifyInstance,
246
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
247
- 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>,
248
277
  done: HookHandlerDoneFunction
249
278
  ): void;
250
279
  }
@@ -254,12 +283,14 @@ export interface onResponseAsyncHookHandler<
254
283
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
255
284
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
256
285
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
257
- ContextConfig = ContextConfigDefault
286
+ ContextConfig = ContextConfigDefault,
287
+ SchemaCompiler extends FastifySchema = FastifySchema,
288
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
258
289
  > {
259
290
  (
260
291
  this: FastifyInstance,
261
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
262
- 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>
263
294
  ): Promise<unknown>;
264
295
  }
265
296
 
@@ -272,12 +303,14 @@ export interface onTimeoutHookHandler<
272
303
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
273
304
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
274
305
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
275
- ContextConfig = ContextConfigDefault
306
+ ContextConfig = ContextConfigDefault,
307
+ SchemaCompiler extends FastifySchema = FastifySchema,
308
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
276
309
  > {
277
310
  (
278
311
  this: FastifyInstance,
279
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
280
- 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>,
281
314
  done: HookHandlerDoneFunction
282
315
  ): void;
283
316
  }
@@ -287,12 +320,14 @@ export interface onTimeoutAsyncHookHandler<
287
320
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
288
321
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
289
322
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
290
- ContextConfig = ContextConfigDefault
323
+ ContextConfig = ContextConfigDefault,
324
+ SchemaCompiler extends FastifySchema = FastifySchema,
325
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
291
326
  > {
292
327
  (
293
328
  this: FastifyInstance,
294
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
295
- 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>
296
331
  ): Promise<unknown>;
297
332
  }
298
333
 
@@ -308,12 +343,14 @@ export interface onErrorHookHandler<
308
343
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
309
344
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
310
345
  ContextConfig = ContextConfigDefault,
311
- TError extends Error = FastifyError
346
+ TError extends Error = FastifyError,
347
+ SchemaCompiler extends FastifySchema = FastifySchema,
348
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
312
349
  > {
313
350
  (
314
351
  this: FastifyInstance,
315
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
316
- 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>,
317
354
  error: TError,
318
355
  done: () => void
319
356
  ): void;
@@ -325,12 +362,14 @@ export interface onErrorAsyncHookHandler<
325
362
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
326
363
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
327
364
  ContextConfig = ContextConfigDefault,
328
- TError extends Error = FastifyError
365
+ TError extends Error = FastifyError,
366
+ SchemaCompiler extends FastifySchema = FastifySchema,
367
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
329
368
  > {
330
369
  (
331
370
  this: FastifyInstance,
332
- request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
333
- 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>,
334
373
  error: TError
335
374
  ): Promise<unknown>;
336
375
  }
@@ -345,11 +384,13 @@ export interface onRouteHookHandler<
345
384
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
346
385
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
347
386
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
348
- ContextConfig = ContextConfigDefault
387
+ ContextConfig = ContextConfigDefault,
388
+ SchemaCompiler extends FastifySchema = FastifySchema,
389
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
349
390
  > {
350
391
  (
351
392
  this: FastifyInstance,
352
- 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 }
353
394
  ): Promise<unknown> | void;
354
395
  }
355
396
 
@@ -363,10 +404,11 @@ export interface onRegisterHookHandler<
363
404
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
364
405
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
365
406
  Logger = FastifyLoggerInstance,
407
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
366
408
  Options extends FastifyPluginOptions = FastifyPluginOptions
367
409
  > {
368
410
  (
369
- instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger>,
411
+ instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
370
412
  opts: RegisterOptions & Options,
371
413
  done: HookHandlerDoneFunction
372
414
  ): Promise<unknown> | void; // documentation is missing the `done` method
@@ -394,10 +436,11 @@ export interface onCloseHookHandler<
394
436
  RawServer extends RawServerBase = RawServerDefault,
395
437
  RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
396
438
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
397
- Logger = FastifyLoggerInstance
439
+ Logger = FastifyLoggerInstance,
440
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
398
441
  > {
399
442
  (
400
- instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger>,
443
+ instance: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
401
444
  done: HookHandlerDoneFunction
402
445
  ): void;
403
446
  }