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
@@ -0,0 +1,257 @@
1
+ <h1 align="center">Fastify</h1>
2
+
3
+ ## Type Providers
4
+
5
+ Type Providers are a TypeScript only feature that enables Fastify to statically infer type information directly from inline JSON Schema. They are an alternative to specifying generic arguments on routes; and can greatly reduce the need to keep associated types for each schema defined in your project.
6
+
7
+ ### Providers
8
+
9
+ Type Providers are offered as additional packages you will need to install into your project. Each provider uses a different inference library under the hood; allowing you to select the library most appropriate for your needs. Type Provider packages follow a `fastify-type-provider-{provider-name}` naming convention.
10
+
11
+ The following inference packages are supported:
12
+
13
+ - `json-schema-to-ts` - [github](https://github.com/ThomasAribart/json-schema-to-ts)
14
+ - `typebox` - [github](https://github.com/sinclairzx81/typebox)
15
+
16
+ ### Json Schema to Ts
17
+
18
+ The following sets up a `json-schema-to-ts` Type Provider
19
+
20
+ ```bash
21
+ $ npm install fastify-type-provider-json-schema-to-ts --save
22
+ ```
23
+
24
+ ```typescript
25
+ import { JsonSchemaToTsTypeProvider } from 'fastify-type-provider-json-schema-to-ts'
26
+
27
+ import fastify from 'fastify'
28
+
29
+ const server = fastify().withTypeProvider<JsonSchemaToTsTypeProvider>()
30
+
31
+ server.get('/route', {
32
+ schema: {
33
+ querystring: {
34
+ type: 'object',
35
+ properties: {
36
+ foo: { type: 'number' },
37
+ bar: { type: 'string' },
38
+ },
39
+ required: ['foo', 'bar']
40
+ }
41
+ } as const // don't forget to use const !
42
+
43
+ }, (request, reply) => {
44
+
45
+ // type Query = { foo: number, bar: string }
46
+
47
+ const { foo, bar } = request.query // type safe!
48
+ })
49
+ ```
50
+
51
+ ### TypeBox
52
+
53
+ The following sets up a TypeBox Type Provider
54
+
55
+ ```bash
56
+ $ npm install fastify-type-provider-typebox --save
57
+ ```
58
+
59
+ ```typescript
60
+ import { TypeBoxTypeProvider, Type } from 'fastify-type-provider-typebox'
61
+
62
+ import fastify from 'fastify'
63
+
64
+ const server = fastify({
65
+ ajv: {
66
+ customOptions: {
67
+ strict: 'log',
68
+ keywords: ['kind', 'modifier'],
69
+ },
70
+ },
71
+ }).withTypeProvider<TypeBoxTypeProvider>()
72
+
73
+ server.get('/route', {
74
+ schema: {
75
+ querystring: Type.Object({
76
+ foo: Type.Number(),
77
+ bar: Type.String()
78
+ })
79
+ }
80
+ }, (request, reply) => {
81
+
82
+ // type Query = { foo: number, bar: string }
83
+
84
+ const { foo, bar } = request.query // type safe!
85
+ })
86
+ ```
87
+
88
+ TypeBox uses the properties `kind` and `modifier` internally. These properties are not strictly valid JSON schema which will cause `AJV@7` and newer versions to throw an invalid schema error. To remove the error it's either necessary to omit the properties by using [`Type.Strict()`](https://github.com/sinclairzx81/typebox#strict) or use the AJV options for adding custom keywords.
89
+
90
+ See also the [TypeBox documentation](https://github.com/sinclairzx81/typebox#validation) on how to set up AJV to work with TypeBox.
91
+
92
+ ### Scoped Type-Provider
93
+
94
+ The provider types don't propagate globally. In encapsulated usage, one can remap the context to use one or more providers (for example, `typebox` and `json-schema-to-ts` can be used in the same application).
95
+
96
+ Example:
97
+
98
+ ```ts
99
+ import Fastify from 'fastify'
100
+ import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
101
+ import { JsonSchemaToTsProvider } from '@fastify/type-provider-json-schema-to-ts'
102
+ import { Type } from '@sinclair/typebox'
103
+
104
+ const fastify = Fastify()
105
+
106
+ function pluginWithTypebox(fastify: FastifyInstance, _opts, done): void {
107
+ fastify.withTypeProvider<TypeBoxTypeProvider>()
108
+ .get('/', {
109
+ schema: {
110
+ body: Type.Object({
111
+ x: Type.String(),
112
+ y: Type.Number(),
113
+ z: Type.Boolean()
114
+ })
115
+ }
116
+ }, (req) => {
117
+ const { x, y, z } = req.body // type safe
118
+ });
119
+ done()
120
+ }
121
+
122
+ function pluginWithJsonSchema(fastify: FastifyInstance, _opts, done): void {
123
+ fastify.withTypeProvider<JsonSchemaToTsProvider>()
124
+ .get('/', {
125
+ schema: {
126
+ body: {
127
+ type: 'object',
128
+ properties: {
129
+ x: { type: 'string' },
130
+ y: { type: 'number' },
131
+ z: { type: 'boolean' }
132
+ },
133
+ } as const
134
+ }
135
+ }, (req) => {
136
+ const { x, y, z } = req.body // type safe
137
+ });
138
+ done()
139
+ }
140
+
141
+ fastify.register(pluginWithJsonSchema)
142
+ fastify.register(pluginWithTypebox)
143
+ ```
144
+
145
+ It's also important to mention that once the types don't propagate globally, _currently_ is not possible to avoid multiple registrations on routes when dealing with several scopes, see bellow:
146
+
147
+ ```ts
148
+ import Fastify from 'fastify'
149
+ import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
150
+ import { Type } from '@sinclair/typebox'
151
+
152
+ const server = Fastify({
153
+ ajv: {
154
+ customOptions: {
155
+ strict: 'log',
156
+ keywords: ['kind', 'modifier'],
157
+ },
158
+ },
159
+ }).withTypeProvider<TypeBoxTypeProvider>()
160
+
161
+ server.register(plugin1) // wrong
162
+ server.register(plugin2) // correct
163
+
164
+ function plugin1(fastify: FastifyInstance, _opts, done): void {
165
+ fastify.get('/', {
166
+ schema: {
167
+ body: Type.Object({
168
+ x: Type.String(),
169
+ y: Type.Number(),
170
+ z: Type.Boolean()
171
+ })
172
+ }
173
+ }, (req) => {
174
+ // it doesn't works! in a new scope needs to call `withTypeProvider` again
175
+ const { x, y, z } = req.body
176
+ });
177
+ done()
178
+ }
179
+
180
+ function plugin2(fastify: FastifyInstance, _opts, done): void {
181
+ const server = fastify.withTypeProvider<TypeBoxTypeProvider>()
182
+
183
+ server.get('/', {
184
+ schema: {
185
+ body: Type.Object({
186
+ x: Type.String(),
187
+ y: Type.Number(),
188
+ z: Type.Boolean()
189
+ })
190
+ }
191
+ }, (req) => {
192
+ // works
193
+ const { x, y, z } = req.body
194
+ });
195
+ done()
196
+ }
197
+ ```
198
+
199
+ ### Type Definition of FastifyInstance + TypeProvider
200
+
201
+ When working with modules one has to make use of `FastifyInstance` with Type Provider generics. See the example below:
202
+
203
+ ```ts
204
+ // index.ts
205
+ import Fastify from 'fastify'
206
+ import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
207
+ import { registerRoutes } from './routes'
208
+
209
+ const server = Fastify({
210
+ ajv: {
211
+ customOptions: {
212
+ strict: 'log',
213
+ keywords: ['kind', 'modifier'],
214
+ },
215
+ },
216
+ }).withTypeProvider<TypeBoxTypeProvider>()
217
+
218
+ registerRoutes(server)
219
+
220
+ server.listen(3000)
221
+ ```
222
+
223
+ ```ts
224
+ // routes.ts
225
+ import { Type } from '@sinclair/typebox'
226
+ import {
227
+ FastifyInstance,
228
+ FastifyLoggerInstance,
229
+ RawReplyDefaultExpression,
230
+ RawRequestDefaultExpression,
231
+ RawServerDefault
232
+ } from 'fastify'
233
+ import { TypeBoxTypeProvider } from '@fastify/type-provider-typebox'
234
+
235
+ type FastifyTypebox = FastifyInstance<
236
+ RawServerDefault,
237
+ RawRequestDefaultExpression<RawServerDefault>,
238
+ RawReplyDefaultExpression<RawServerDefault>,
239
+ FastifyLoggerInstance,
240
+ TypeBoxTypeProvider
241
+ >;
242
+
243
+ export function registerRoutes(fastify: FastifyTypebox): void {
244
+ fastify.get('/', {
245
+ schema: {
246
+ body: Type.Object({
247
+ x: Type.String(),
248
+ y: Type.Number(),
249
+ z: Type.Boolean()
250
+ })
251
+ }
252
+ }, (req) => {
253
+ // works
254
+ const { x, y, z } = req.body
255
+ });
256
+ }
257
+ ```
package/examples/hooks.js CHANGED
@@ -37,7 +37,7 @@ fastify
37
37
  console.log('onRequest')
38
38
  done()
39
39
  })
40
- .addHook('preParsing', function (request, reply, done) {
40
+ .addHook('preParsing', function (request, reply, payload, done) {
41
41
  console.log('preParsing')
42
42
  done()
43
43
  })
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ const fastify = require('../fastify')({
4
+ logger: false
5
+ })
6
+
7
+ const Readable = require('stream').Readable
8
+
9
+ fastify
10
+ .get('/', function (req, reply) {
11
+ const stream = Readable.from(['hello world'])
12
+ reply.send(stream)
13
+ })
14
+
15
+ fastify.listen(3000, (err, address) => {
16
+ if (err) throw err
17
+ fastify.log.info(`server listening on ${address}`)
18
+ })
package/fastify.d.ts CHANGED
@@ -5,18 +5,21 @@ import { ConstraintStrategy, HTTPVersion } from 'find-my-way'
5
5
 
6
6
  import { FastifyRequest, RequestGenericInterface } from './types/request'
7
7
  import { RawServerBase, RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression } from './types/utils'
8
- import { FastifyLoggerInstance, FastifyLoggerOptions } from './types/logger'
8
+ import { FastifyBaseLogger, FastifyLoggerInstance, FastifyLoggerOptions, PinoLoggerOptions } from './types/logger'
9
9
  import { FastifyInstance } from './types/instance'
10
10
  import { FastifyServerFactory } from './types/serverFactory'
11
11
  import { Options as AjvOptions } from '@fastify/ajv-compiler'
12
+ import { Options as FJSOptions } from '@fastify/fast-json-stringify-compiler'
12
13
  import { FastifyError } from 'fastify-error'
13
14
  import { FastifyReply } from './types/reply'
14
15
  import { FastifySchemaValidationError } from './types/schema'
15
16
  import { ConstructorAction, ProtoAction } from "./types/content-type-parser";
16
17
  import { Socket } from 'net'
17
- import { Options as FJSOptions } from 'fast-json-stringify'
18
18
  import { ValidatorCompiler } from '@fastify/ajv-compiler'
19
- import { FastifySerializerCompiler } from './types/schema';
19
+ import { SerializerCompiler } from '@fastify/fast-json-stringify-compiler'
20
+ import { FastifySchema } from './types/schema'
21
+ import { FastifyContextConfig } from './types/context'
22
+ import { FastifyTypeProvider, FastifyTypeProviderDefault } from './types/type-provider'
20
23
 
21
24
  /**
22
25
  * Fastify factory function for the standard fastify http, https, or http2 server instance.
@@ -30,31 +33,39 @@ declare function fastify<
30
33
  Server extends http2.Http2SecureServer,
31
34
  Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
32
35
  Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
33
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
34
- >(opts: FastifyHttp2SecureOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger>>
36
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance,
37
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
38
+ >(opts: FastifyHttp2SecureOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
39
+
35
40
  declare function fastify<
36
41
  Server extends http2.Http2Server,
37
42
  Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
38
43
  Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
39
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
40
- >(opts: FastifyHttp2Options<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger>>
44
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance,
45
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
46
+ >(opts: FastifyHttp2Options<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
47
+
41
48
  declare function fastify<
42
49
  Server extends https.Server,
43
50
  Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
44
51
  Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
45
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
46
- >(opts: FastifyHttpsOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger>>
52
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance,
53
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
54
+ >(opts: FastifyHttpsOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
55
+
47
56
  declare function fastify<
48
57
  Server extends http.Server,
49
58
  Request extends RawRequestDefaultExpression<Server> = RawRequestDefaultExpression<Server>,
50
59
  Reply extends RawReplyDefaultExpression<Server> = RawReplyDefaultExpression<Server>,
51
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
52
- >(opts?: FastifyServerOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger>>
60
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance,
61
+ TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
62
+ >(opts?: FastifyServerOptions<Server, Logger>): FastifyInstance<Server, Request, Reply, Logger, TypeProvider> & PromiseLike<FastifyInstance<Server, Request, Reply, Logger, TypeProvider>>
63
+
53
64
  export default fastify
54
65
 
55
66
  export type FastifyHttp2SecureOptions<
56
67
  Server extends http2.Http2SecureServer,
57
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
68
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance
58
69
  > = FastifyServerOptions<Server, Logger> & {
59
70
  http2: true,
60
71
  https: http2.SecureServerOptions,
@@ -63,7 +74,7 @@ export type FastifyHttp2SecureOptions<
63
74
 
64
75
  export type FastifyHttp2Options<
65
76
  Server extends http2.Http2Server,
66
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
77
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance
67
78
  > = FastifyServerOptions<Server, Logger> & {
68
79
  http2: true,
69
80
  http2SessionTimeout?: number
@@ -71,7 +82,7 @@ export type FastifyHttp2Options<
71
82
 
72
83
  export type FastifyHttpsOptions<
73
84
  Server extends https.Server,
74
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
85
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance
75
86
  > = FastifyServerOptions<Server, Logger> & {
76
87
  https: https.ServerOptions
77
88
  }
@@ -92,12 +103,13 @@ export interface ConnectionError extends Error {
92
103
  */
93
104
  export type FastifyServerOptions<
94
105
  RawServer extends RawServerBase = RawServerDefault,
95
- Logger extends FastifyLoggerInstance = FastifyLoggerInstance
106
+ Logger extends FastifyBaseLogger = FastifyLoggerInstance
96
107
  > = {
97
108
  ignoreTrailingSlash?: boolean,
98
109
  connectionTimeout?: number,
99
110
  keepAliveTimeout?: number,
100
111
  maxRequestsPerSocket?: number,
112
+ forceCloseConnections?: boolean,
101
113
  requestTimeout?: number,
102
114
  pluginTimeout?: number,
103
115
  bodyLimit?: number,
@@ -106,13 +118,14 @@ export type FastifyServerOptions<
106
118
  exposeHeadRoutes?: boolean,
107
119
  onProtoPoisoning?: ProtoAction,
108
120
  onConstructorPoisoning?: ConstructorAction,
109
- logger?: boolean | FastifyLoggerOptions<RawServer> | Logger,
121
+ logger?: boolean | FastifyLoggerOptions<RawServer> & PinoLoggerOptions | Logger,
110
122
  serializerOpts?: FJSOptions | Record<string, unknown>,
111
123
  serverFactory?: FastifyServerFactory<RawServer>,
112
124
  caseSensitive?: boolean,
113
125
  requestIdHeader?: string,
114
126
  requestIdLogLabel?: string;
115
- genReqId?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface>(req: FastifyRequest<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>>) => string,
127
+ jsonShorthand?: boolean;
128
+ genReqId?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault>(req: FastifyRequest<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, TypeProvider>) => string,
116
129
  trustProxy?: boolean | string | string[] | number | TrustProxyFunction,
117
130
  querystringParser?: (str: string) => { [key: string]: unknown },
118
131
  /**
@@ -138,7 +151,7 @@ export type FastifyServerOptions<
138
151
  };
139
152
  compilersFactory?: {
140
153
  buildValidator?: ValidatorCompiler;
141
- buildSerializer?: (externalSchemas: unknown, serializerOptsServerOption: FastifyServerOptions["serializerOpts"]) => FastifySerializerCompiler<unknown>;
154
+ buildSerializer?: SerializerCompiler;
142
155
  };
143
156
  };
144
157
  return503OnClosing?: boolean,
@@ -146,10 +159,10 @@ export type FastifyServerOptions<
146
159
  customOptions?: AjvOptions,
147
160
  plugins?: (Function | [Function, unknown])[]
148
161
  },
149
- frameworkErrors?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface>(
162
+ frameworkErrors?: <RequestGeneric extends RequestGenericInterface = RequestGenericInterface, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, SchemaCompiler extends FastifySchema = FastifySchema>(
150
163
  error: FastifyError,
151
- req: FastifyRequest<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>>,
152
- res: FastifyReply<RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>>
164
+ req: FastifyRequest<RequestGeneric, RawServer, RawRequestDefaultExpression<RawServer>, FastifySchema, TypeProvider>,
165
+ res: FastifyReply<RawServer, RawRequestDefaultExpression<RawServer>, RawReplyDefaultExpression<RawServer>, RequestGeneric, FastifyContextConfig, SchemaCompiler, TypeProvider>
153
166
  ) => void,
154
167
  rewriteUrl?: (req: RawRequestDefaultExpression<RawServer>) => string,
155
168
  schemaErrorFormatter?: (errors: FastifySchemaValidationError[], dataVar: string) => Error,
@@ -181,7 +194,7 @@ export { FastifyRequest, RequestGenericInterface } from './types/request'
181
194
  export { FastifyReply } from './types/reply'
182
195
  export { FastifyPluginCallback, FastifyPluginAsync, FastifyPluginOptions, FastifyPlugin } from './types/plugin'
183
196
  export { FastifyInstance, PrintRoutesOptions } from './types/instance'
184
- export { FastifyLoggerOptions, FastifyLoggerInstance, FastifyLogFn, LogLevel } from './types/logger'
197
+ export { FastifyLoggerOptions, FastifyBaseLogger, FastifyLoggerInstance, FastifyLogFn, LogLevel } from './types/logger'
185
198
  export { FastifyContext, FastifyContextConfig } from './types/context'
186
199
  export { RouteHandler, RouteHandlerMethod, RouteOptions, RouteShorthandMethod, RouteShorthandOptions, RouteShorthandOptionsWithHandler } from './types/route'
187
200
  export * from './types/register'
@@ -191,4 +204,5 @@ export { FastifySchema, FastifySchemaCompiler } from './types/schema'
191
204
  export { HTTPMethods, RawServerBase, RawRequestDefaultExpression, RawReplyDefaultExpression, RawServerDefault, ContextConfigDefault, RequestBodyDefault, RequestQuerystringDefault, RequestParamsDefault, RequestHeadersDefault } from './types/utils'
192
205
  export * from './types/hooks'
193
206
  export { FastifyServerFactory, FastifyServerFactoryHandler } from './types/serverFactory'
207
+ export { FastifyTypeProvider, FastifyTypeProviderDefault } from './types/type-provider'
194
208
  export { fastify }