fastify 4.2.1 → 4.3.0
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.
- package/docs/Guides/Ecosystem.md +2 -0
- package/docs/Reference/HTTP2.md +1 -3
- package/docs/Reference/Reply.md +176 -0
- package/docs/Reference/Request.md +171 -0
- package/fastify.d.ts +1 -1
- package/fastify.js +2 -2
- package/lib/contentTypeParser.js +10 -2
- package/lib/context.js +10 -1
- package/lib/errors.js +8 -0
- package/lib/reply.js +80 -2
- package/lib/request.js +97 -1
- package/lib/route.js +2 -0
- package/lib/symbols.js +15 -9
- package/package.json +1 -1
- package/test/content-parser.test.js +15 -0
- package/test/internals/reply-serialize.test.js +583 -0
- package/test/internals/request-validate.test.js +1269 -0
- package/test/internals/request.test.js +11 -2
- package/test/request-error.test.js +44 -1
- package/test/types/hooks.test-d.ts +1 -2
- package/test/types/import.ts +1 -1
- package/test/types/request.test-d.ts +1 -1
- package/test/types/type-provider.test-d.ts +76 -6
- package/types/hooks.d.ts +19 -39
- package/types/instance.d.ts +19 -39
- package/types/reply.d.ts +5 -0
- package/types/request.d.ts +16 -3
- package/types/route.d.ts +23 -29
- package/types/type-provider.d.ts +7 -6
|
@@ -19,6 +19,9 @@ test('Regular request', t => {
|
|
|
19
19
|
req.connection = req.socket
|
|
20
20
|
const request = new Request('id', 'params', req, 'query', 'log')
|
|
21
21
|
t.type(request, Request)
|
|
22
|
+
t.type(request.validateInput, Function)
|
|
23
|
+
t.type(request.getValidationFunction, Function)
|
|
24
|
+
t.type(request.compileValidationSchema, Function)
|
|
22
25
|
t.equal(request.id, 'id')
|
|
23
26
|
t.equal(request.params, 'params')
|
|
24
27
|
t.equal(request.raw, req)
|
|
@@ -74,7 +77,7 @@ test('Regular request - host header has precedence over authority', t => {
|
|
|
74
77
|
})
|
|
75
78
|
|
|
76
79
|
test('Request with trust proxy', t => {
|
|
77
|
-
t.plan(
|
|
80
|
+
t.plan(18)
|
|
78
81
|
const headers = {
|
|
79
82
|
'x-forwarded-for': '2.2.2.2, 1.1.1.1',
|
|
80
83
|
'x-forwarded-host': 'example.com'
|
|
@@ -103,6 +106,9 @@ test('Request with trust proxy', t => {
|
|
|
103
106
|
t.equal(request.url, '/')
|
|
104
107
|
t.equal(request.socket, req.socket)
|
|
105
108
|
t.equal(request.protocol, 'http')
|
|
109
|
+
t.type(request.validateInput, Function)
|
|
110
|
+
t.type(request.getValidationFunction, Function)
|
|
111
|
+
t.type(request.compileValidationSchema, Function)
|
|
106
112
|
})
|
|
107
113
|
|
|
108
114
|
test('Request with trust proxy, encrypted', t => {
|
|
@@ -221,7 +227,7 @@ test('Request with trust proxy - plain', t => {
|
|
|
221
227
|
})
|
|
222
228
|
|
|
223
229
|
test('Request with undefined socket', t => {
|
|
224
|
-
t.plan(
|
|
230
|
+
t.plan(18)
|
|
225
231
|
const headers = {
|
|
226
232
|
host: 'hostname'
|
|
227
233
|
}
|
|
@@ -247,6 +253,9 @@ test('Request with undefined socket', t => {
|
|
|
247
253
|
t.equal(request.url, '/')
|
|
248
254
|
t.equal(request.protocol, undefined)
|
|
249
255
|
t.same(request.socket, req.socket)
|
|
256
|
+
t.type(request.validateInput, Function)
|
|
257
|
+
t.type(request.getValidationFunction, Function)
|
|
258
|
+
t.type(request.compileValidationSchema, Function)
|
|
250
259
|
})
|
|
251
260
|
|
|
252
261
|
test('Request with trust proxy and undefined socket', t => {
|
|
@@ -150,7 +150,7 @@ test('default clientError handler ignores sockets in destroyed state', t => {
|
|
|
150
150
|
})
|
|
151
151
|
|
|
152
152
|
test('default clientError handler destroys sockets in writable state', t => {
|
|
153
|
-
t.plan(
|
|
153
|
+
t.plan(2)
|
|
154
154
|
|
|
155
155
|
const fastify = Fastify({
|
|
156
156
|
bodyLimit: 1,
|
|
@@ -166,6 +166,9 @@ test('default clientError handler destroys sockets in writable state', t => {
|
|
|
166
166
|
},
|
|
167
167
|
destroy () {
|
|
168
168
|
t.pass('destroy should be called')
|
|
169
|
+
},
|
|
170
|
+
write (response) {
|
|
171
|
+
t.match(response, /^HTTP\/1.1 400 Bad Request/)
|
|
169
172
|
}
|
|
170
173
|
})
|
|
171
174
|
})
|
|
@@ -186,6 +189,9 @@ test('default clientError handler destroys http sockets in non-writable state',
|
|
|
186
189
|
},
|
|
187
190
|
destroy () {
|
|
188
191
|
t.pass('destroy should be called')
|
|
192
|
+
},
|
|
193
|
+
write (response) {
|
|
194
|
+
t.fail('write should not be called')
|
|
189
195
|
}
|
|
190
196
|
})
|
|
191
197
|
})
|
|
@@ -270,3 +276,40 @@ test('encapsulated error handler binding', t => {
|
|
|
270
276
|
t.equal(fastify.hello, undefined)
|
|
271
277
|
})
|
|
272
278
|
})
|
|
279
|
+
|
|
280
|
+
test('default clientError replies with bad request on reused keep-alive connection', t => {
|
|
281
|
+
t.plan(2)
|
|
282
|
+
|
|
283
|
+
let response = ''
|
|
284
|
+
|
|
285
|
+
const fastify = Fastify({
|
|
286
|
+
bodyLimit: 1,
|
|
287
|
+
keepAliveTimeout: 100
|
|
288
|
+
})
|
|
289
|
+
|
|
290
|
+
fastify.get('/', (request, reply) => {
|
|
291
|
+
reply.send('OK\n')
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
fastify.listen({ port: 0 }, function (err) {
|
|
295
|
+
t.error(err)
|
|
296
|
+
fastify.server.unref()
|
|
297
|
+
|
|
298
|
+
const client = connect(fastify.server.address().port)
|
|
299
|
+
|
|
300
|
+
client.on('data', chunk => {
|
|
301
|
+
response += chunk.toString('utf-8')
|
|
302
|
+
})
|
|
303
|
+
|
|
304
|
+
client.on('end', () => {
|
|
305
|
+
t.match(response, /^HTTP\/1.1 200 OK.*HTTP\/1.1 400 Bad Request/s)
|
|
306
|
+
})
|
|
307
|
+
|
|
308
|
+
client.resume()
|
|
309
|
+
client.write('GET / HTTP/1.1\r\n')
|
|
310
|
+
client.write('\r\n\r\n')
|
|
311
|
+
client.write('GET /?a b HTTP/1.1\r\n')
|
|
312
|
+
client.write('Connection: close\r\n')
|
|
313
|
+
client.write('\r\n\r\n')
|
|
314
|
+
})
|
|
315
|
+
})
|
|
@@ -223,8 +223,7 @@ RawReplyDefaultExpression,
|
|
|
223
223
|
RouteGenericInterface,
|
|
224
224
|
ContextConfigDefault,
|
|
225
225
|
FastifySchema,
|
|
226
|
-
FastifyTypeProviderDefault
|
|
227
|
-
ResolveFastifyRequestType<FastifyTypeProviderDefault, FastifySchema, RouteGenericInterface>
|
|
226
|
+
FastifyTypeProviderDefault
|
|
228
227
|
> = async function (request, reply): Promise<void> {
|
|
229
228
|
expectType<FastifyInstance>(this)
|
|
230
229
|
expectAssignable<FastifyRequest>(request)
|
package/test/types/import.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import { FastifyLogFn } from '../../fastify'
|
|
1
|
+
import { FastifyListenOptions, FastifyLogFn } from '../../fastify'
|
|
@@ -85,7 +85,7 @@ const getHandler: RouteHandler = function (request, _reply) {
|
|
|
85
85
|
expectType<FastifyInstance>(request.server)
|
|
86
86
|
}
|
|
87
87
|
|
|
88
|
-
const getHandlerWithCustomLogger: RouteHandlerMethod<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault,
|
|
88
|
+
const getHandlerWithCustomLogger: RouteHandlerMethod<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault, CustomLoggerInterface> = function (request, _reply) {
|
|
89
89
|
expectType<CustomLoggerInterface>(request.log)
|
|
90
90
|
}
|
|
91
91
|
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import fastify, {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
FastifyTypeProvider,
|
|
3
|
+
HookHandlerDoneFunction,
|
|
4
|
+
FastifyRequest,
|
|
5
|
+
FastifyReply,
|
|
6
|
+
FastifyInstance
|
|
7
7
|
} from '../../fastify'
|
|
8
8
|
import { expectAssignable, expectError, expectType } from 'tsd'
|
|
9
9
|
import { IncomingHttpHeaders } from 'http'
|
|
10
10
|
import { Type, TSchema, Static } from '@sinclair/typebox'
|
|
11
11
|
import { FromSchema, JSONSchema } from 'json-schema-to-ts'
|
|
12
|
-
import { RouteGenericInterface } from '../../types/route'
|
|
13
12
|
|
|
14
13
|
const server = fastify()
|
|
15
14
|
|
|
@@ -437,3 +436,74 @@ expectAssignable(server.withTypeProvider<JsonSchemaToTsProvider>().get<{Reply: b
|
|
|
437
436
|
return true
|
|
438
437
|
}
|
|
439
438
|
))
|
|
439
|
+
|
|
440
|
+
// -------------------------------------------------------------------
|
|
441
|
+
// FastifyPlugin: Auxiliary
|
|
442
|
+
// -------------------------------------------------------------------
|
|
443
|
+
|
|
444
|
+
interface AuxiliaryPluginProvider extends FastifyTypeProvider { output: 'plugin-auxiliary' }
|
|
445
|
+
|
|
446
|
+
// Auxiliary plugins may have varying server types per application. Recommendation would be to explicitly remap instance provider context within plugin if required.
|
|
447
|
+
function plugin<T extends FastifyInstance> (instance: T) {
|
|
448
|
+
expectAssignable(instance.withTypeProvider<AuxiliaryPluginProvider>().get(
|
|
449
|
+
'/',
|
|
450
|
+
{
|
|
451
|
+
schema: { body: null }
|
|
452
|
+
},
|
|
453
|
+
(req) => {
|
|
454
|
+
expectType<'plugin-auxiliary'>(req.body)
|
|
455
|
+
}
|
|
456
|
+
))
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
expectAssignable(server.withTypeProvider<AuxiliaryPluginProvider>().register(plugin).get(
|
|
460
|
+
'/',
|
|
461
|
+
{
|
|
462
|
+
schema: { body: null }
|
|
463
|
+
},
|
|
464
|
+
(req) => {
|
|
465
|
+
expectType<'plugin-auxiliary'>(req.body)
|
|
466
|
+
}
|
|
467
|
+
))
|
|
468
|
+
|
|
469
|
+
// -------------------------------------------------------------------
|
|
470
|
+
// Handlers: Inline
|
|
471
|
+
// -------------------------------------------------------------------
|
|
472
|
+
|
|
473
|
+
interface InlineHandlerProvider extends FastifyTypeProvider { output: 'handler-inline' }
|
|
474
|
+
|
|
475
|
+
// Inline handlers should infer for the request parameters (non-shared)
|
|
476
|
+
expectAssignable(server.withTypeProvider<InlineHandlerProvider>().get(
|
|
477
|
+
'/',
|
|
478
|
+
{
|
|
479
|
+
onRequest: (req, res) => {
|
|
480
|
+
expectType<'handler-inline'>(req.body)
|
|
481
|
+
},
|
|
482
|
+
schema: { body: null }
|
|
483
|
+
},
|
|
484
|
+
(req) => {
|
|
485
|
+
expectType<'handler-inline'>(req.body)
|
|
486
|
+
}
|
|
487
|
+
))
|
|
488
|
+
|
|
489
|
+
// -------------------------------------------------------------------
|
|
490
|
+
// Handlers: Auxiliary
|
|
491
|
+
// -------------------------------------------------------------------
|
|
492
|
+
|
|
493
|
+
interface AuxiliaryHandlerProvider extends FastifyTypeProvider { output: 'handler-auxiliary' }
|
|
494
|
+
|
|
495
|
+
// Auxiliary handlers are likely shared for multiple routes and thus should infer as unknown due to potential varying parameters
|
|
496
|
+
function auxiliaryHandler (request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction): void {
|
|
497
|
+
expectType<unknown>(request.body)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
expectAssignable(server.withTypeProvider<AuxiliaryHandlerProvider>().get(
|
|
501
|
+
'/',
|
|
502
|
+
{
|
|
503
|
+
onRequest: auxiliaryHandler,
|
|
504
|
+
schema: { body: null }
|
|
505
|
+
},
|
|
506
|
+
(req) => {
|
|
507
|
+
expectType<'handler-auxiliary'>(req.body)
|
|
508
|
+
}
|
|
509
|
+
))
|
package/types/hooks.d.ts
CHANGED
|
@@ -7,10 +7,8 @@ import { FastifyReply } from './reply'
|
|
|
7
7
|
import { FastifyError } from '@fastify/error'
|
|
8
8
|
import { FastifyLoggerInstance } from './logger'
|
|
9
9
|
import {
|
|
10
|
-
FastifyRequestType,
|
|
11
10
|
FastifyTypeProvider,
|
|
12
|
-
FastifyTypeProviderDefault
|
|
13
|
-
ResolveFastifyRequestType
|
|
11
|
+
FastifyTypeProviderDefault
|
|
14
12
|
} from './type-provider'
|
|
15
13
|
import { RegisterOptions } from './register'
|
|
16
14
|
import { FastifySchema } from './schema'
|
|
@@ -36,12 +34,11 @@ export interface onRequestHookHandler<
|
|
|
36
34
|
ContextConfig = ContextConfigDefault,
|
|
37
35
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
38
36
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
39
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
40
37
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
41
38
|
> {
|
|
42
39
|
(
|
|
43
40
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
44
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
41
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
45
42
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
46
43
|
done: HookHandlerDoneFunction
|
|
47
44
|
): void;
|
|
@@ -55,12 +52,11 @@ export interface onRequestAsyncHookHandler<
|
|
|
55
52
|
ContextConfig = ContextConfigDefault,
|
|
56
53
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
57
54
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
58
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
59
55
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
60
56
|
> {
|
|
61
57
|
(
|
|
62
58
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
63
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
59
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
64
60
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
65
61
|
): Promise<unknown>;
|
|
66
62
|
}
|
|
@@ -77,12 +73,11 @@ export interface preParsingHookHandler<
|
|
|
77
73
|
ContextConfig = ContextConfigDefault,
|
|
78
74
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
79
75
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
80
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
81
76
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
82
77
|
> {
|
|
83
78
|
(
|
|
84
79
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
85
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
80
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
86
81
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
87
82
|
payload: RequestPayload,
|
|
88
83
|
done: <TError extends Error = FastifyError>(err?: TError | null, res?: RequestPayload) => void
|
|
@@ -97,12 +92,11 @@ export interface preParsingAsyncHookHandler<
|
|
|
97
92
|
ContextConfig = ContextConfigDefault,
|
|
98
93
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
99
94
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
100
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
101
95
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
102
96
|
> {
|
|
103
97
|
(
|
|
104
98
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
105
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
99
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
106
100
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
107
101
|
payload: RequestPayload,
|
|
108
102
|
): Promise<RequestPayload | unknown>;
|
|
@@ -119,12 +113,11 @@ export interface preValidationHookHandler<
|
|
|
119
113
|
ContextConfig = ContextConfigDefault,
|
|
120
114
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
121
115
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
122
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
123
116
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
124
117
|
> {
|
|
125
118
|
(
|
|
126
119
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
127
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
120
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
128
121
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
129
122
|
done: HookHandlerDoneFunction
|
|
130
123
|
): void;
|
|
@@ -138,12 +131,11 @@ export interface preValidationAsyncHookHandler<
|
|
|
138
131
|
ContextConfig = ContextConfigDefault,
|
|
139
132
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
140
133
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
141
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
142
134
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
143
135
|
> {
|
|
144
136
|
(
|
|
145
137
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
146
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
138
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
147
139
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
148
140
|
): Promise<unknown>;
|
|
149
141
|
}
|
|
@@ -159,12 +151,11 @@ export interface preHandlerHookHandler<
|
|
|
159
151
|
ContextConfig = ContextConfigDefault,
|
|
160
152
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
161
153
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
162
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
163
154
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
164
155
|
> {
|
|
165
156
|
(
|
|
166
157
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
167
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
158
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
168
159
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
169
160
|
done: HookHandlerDoneFunction
|
|
170
161
|
): void;
|
|
@@ -178,12 +169,11 @@ export interface preHandlerAsyncHookHandler<
|
|
|
178
169
|
ContextConfig = ContextConfigDefault,
|
|
179
170
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
180
171
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
181
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
182
172
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
183
173
|
> {
|
|
184
174
|
(
|
|
185
175
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
186
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
176
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
187
177
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
188
178
|
): Promise<unknown>;
|
|
189
179
|
}
|
|
@@ -208,12 +198,11 @@ export interface preSerializationHookHandler<
|
|
|
208
198
|
ContextConfig = ContextConfigDefault,
|
|
209
199
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
210
200
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
211
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
212
201
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
213
202
|
> {
|
|
214
203
|
(
|
|
215
204
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
216
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
205
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
217
206
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
218
207
|
payload: PreSerializationPayload,
|
|
219
208
|
done: DoneFuncWithErrOrRes
|
|
@@ -229,12 +218,11 @@ export interface preSerializationAsyncHookHandler<
|
|
|
229
218
|
ContextConfig = ContextConfigDefault,
|
|
230
219
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
231
220
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
232
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
233
221
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
234
222
|
> {
|
|
235
223
|
(
|
|
236
224
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
237
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
225
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
238
226
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
239
227
|
payload: PreSerializationPayload
|
|
240
228
|
): Promise<unknown>;
|
|
@@ -253,12 +241,11 @@ export interface onSendHookHandler<
|
|
|
253
241
|
ContextConfig = ContextConfigDefault,
|
|
254
242
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
255
243
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
256
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
257
244
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
258
245
|
> {
|
|
259
246
|
(
|
|
260
247
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
261
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
248
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
262
249
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
263
250
|
payload: OnSendPayload,
|
|
264
251
|
done: DoneFuncWithErrOrRes
|
|
@@ -274,12 +261,11 @@ export interface onSendAsyncHookHandler<
|
|
|
274
261
|
ContextConfig = ContextConfigDefault,
|
|
275
262
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
276
263
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
277
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
278
264
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
279
265
|
> {
|
|
280
266
|
(
|
|
281
267
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
282
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
268
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
283
269
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
284
270
|
payload: OnSendPayload,
|
|
285
271
|
): Promise<unknown>;
|
|
@@ -297,12 +283,11 @@ export interface onResponseHookHandler<
|
|
|
297
283
|
ContextConfig = ContextConfigDefault,
|
|
298
284
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
299
285
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
300
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
301
286
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
302
287
|
> {
|
|
303
288
|
(
|
|
304
289
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
305
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
290
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
306
291
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
307
292
|
done: HookHandlerDoneFunction
|
|
308
293
|
): void;
|
|
@@ -316,12 +301,11 @@ export interface onResponseAsyncHookHandler<
|
|
|
316
301
|
ContextConfig = ContextConfigDefault,
|
|
317
302
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
318
303
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
319
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
320
304
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
321
305
|
> {
|
|
322
306
|
(
|
|
323
307
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
324
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
308
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
325
309
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
326
310
|
): Promise<unknown>;
|
|
327
311
|
}
|
|
@@ -338,12 +322,11 @@ export interface onTimeoutHookHandler<
|
|
|
338
322
|
ContextConfig = ContextConfigDefault,
|
|
339
323
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
340
324
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
341
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
342
325
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
343
326
|
> {
|
|
344
327
|
(
|
|
345
328
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
346
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
329
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
347
330
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
348
331
|
done: HookHandlerDoneFunction
|
|
349
332
|
): void;
|
|
@@ -357,12 +340,11 @@ export interface onTimeoutAsyncHookHandler<
|
|
|
357
340
|
ContextConfig = ContextConfigDefault,
|
|
358
341
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
359
342
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
360
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
361
343
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
362
344
|
> {
|
|
363
345
|
(
|
|
364
346
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
365
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
347
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
366
348
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
367
349
|
): Promise<unknown>;
|
|
368
350
|
}
|
|
@@ -382,12 +364,11 @@ export interface onErrorHookHandler<
|
|
|
382
364
|
TError extends Error = FastifyError,
|
|
383
365
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
384
366
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
385
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
386
367
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
387
368
|
> {
|
|
388
369
|
(
|
|
389
370
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
390
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
371
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
391
372
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
392
373
|
error: TError,
|
|
393
374
|
done: () => void
|
|
@@ -403,12 +384,11 @@ export interface onErrorAsyncHookHandler<
|
|
|
403
384
|
TError extends Error = FastifyError,
|
|
404
385
|
SchemaCompiler extends FastifySchema = FastifySchema,
|
|
405
386
|
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
406
|
-
RequestType extends FastifyRequestType = ResolveFastifyRequestType<TypeProvider, SchemaCompiler, RouteGeneric>,
|
|
407
387
|
Logger extends FastifyLoggerInstance = FastifyLoggerInstance
|
|
408
388
|
> {
|
|
409
389
|
(
|
|
410
390
|
this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>,
|
|
411
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig,
|
|
391
|
+
request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider, ContextConfig, Logger>,
|
|
412
392
|
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>,
|
|
413
393
|
error: TError
|
|
414
394
|
): Promise<unknown>;
|