fastify 4.2.0 → 4.4.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/README.md +13 -14
- package/docs/Guides/Database.md +2 -2
- package/docs/Guides/Ecosystem.md +42 -18
- package/docs/Guides/Migration-Guide-V4.md +29 -0
- package/docs/Guides/Plugins-Guide.md +5 -0
- package/docs/Reference/HTTP2.md +1 -3
- package/docs/Reference/Hooks.md +4 -1
- package/docs/Reference/Logging.md +1 -1
- package/docs/Reference/Reply.md +177 -0
- package/docs/Reference/Request.md +171 -0
- package/docs/Reference/Routes.md +4 -2
- package/docs/Reference/Server.md +4 -1
- package/docs/Reference/Type-Providers.md +1 -15
- package/docs/Reference/TypeScript.md +27 -3
- package/fastify.d.ts +1 -1
- package/fastify.js +3 -3
- package/lib/contentTypeParser.js +10 -2
- package/lib/context.js +10 -1
- package/lib/error-serializer.js +12 -12
- package/lib/errors.js +8 -0
- package/lib/handleRequest.js +2 -2
- package/lib/httpMethods.js +22 -0
- package/lib/reply.js +101 -24
- package/lib/request.js +97 -1
- package/lib/route.js +3 -1
- package/lib/symbols.js +15 -9
- package/package.json +7 -7
- package/test/build/error-serializer.test.js +3 -1
- package/test/content-parser.test.js +15 -0
- package/test/copy.test.js +41 -0
- package/test/internals/all.test.js +8 -2
- package/test/internals/reply-serialize.test.js +583 -0
- package/test/internals/reply.test.js +4 -1
- package/test/internals/request-validate.test.js +1269 -0
- package/test/internals/request.test.js +11 -2
- package/test/lock.test.js +73 -0
- package/test/mkcol.test.js +38 -0
- package/test/move.test.js +45 -0
- package/test/propfind.test.js +108 -0
- package/test/proppatch.test.js +78 -0
- package/test/request-error.test.js +44 -1
- package/test/schema-validation.test.js +71 -0
- package/test/search.test.js +100 -0
- package/test/trace.test.js +21 -0
- package/test/types/fastify.test-d.ts +12 -1
- package/test/types/hooks.test-d.ts +1 -2
- package/test/types/import.ts +1 -1
- package/test/types/instance.test-d.ts +4 -1
- package/test/types/logger.test-d.ts +4 -5
- package/test/types/reply.test-d.ts +44 -3
- package/test/types/request.test-d.ts +10 -29
- package/test/types/type-provider.test-d.ts +79 -7
- package/test/unlock.test.js +41 -0
- package/test/validation-error-handling.test.js +6 -1
- package/types/hooks.d.ts +19 -39
- package/types/instance.d.ts +78 -130
- package/types/logger.d.ts +7 -4
- package/types/reply.d.ts +7 -1
- package/types/request.d.ts +16 -3
- package/types/route.d.ts +23 -29
- package/types/schema.d.ts +4 -1
- package/types/type-provider.d.ts +8 -20
- package/types/utils.d.ts +2 -1
|
@@ -11,7 +11,7 @@ import { HookHandlerDoneFunction } from '../../types/hooks'
|
|
|
11
11
|
import { FastifyReply } from '../../types/reply'
|
|
12
12
|
import { FastifyRequest } from '../../types/request'
|
|
13
13
|
import { DefaultRoute } from '../../types/route'
|
|
14
|
-
import { FastifySchemaControllerOptions } from '../../types/schema'
|
|
14
|
+
import { FastifySchemaControllerOptions, FastifySchemaCompiler, FastifySerializerCompiler } from '../../types/schema'
|
|
15
15
|
|
|
16
16
|
const server = fastify()
|
|
17
17
|
|
|
@@ -325,3 +325,6 @@ expectType<void>(server.addConstraintStrategy(versionConstraintStrategy))
|
|
|
325
325
|
expectType<boolean>(server.hasConstraintStrategy(versionConstraintStrategy.name))
|
|
326
326
|
|
|
327
327
|
expectAssignable<DefaultRoute<RawRequestDefaultExpression, RawReplyDefaultExpression>>(server.getDefaultRoute())
|
|
328
|
+
|
|
329
|
+
expectType<FastifySchemaCompiler<any> | undefined>(server.validatorCompiler)
|
|
330
|
+
expectType<FastifySerializerCompiler<any> | undefined>(server.serializerCompiler)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expectError, expectType } from 'tsd'
|
|
1
|
+
import { expectDeprecated, expectError, expectType } from 'tsd'
|
|
2
2
|
import fastify, {
|
|
3
3
|
FastifyLogFn,
|
|
4
4
|
LogLevel,
|
|
@@ -24,13 +24,10 @@ class Foo {}
|
|
|
24
24
|
expectType<void>(fastify<Server, IncomingMessage, ServerResponse, FastifyLoggerInstance>().log[logLevel as LogLevel](new Foo()))
|
|
25
25
|
})
|
|
26
26
|
|
|
27
|
-
/*
|
|
28
|
-
// TODO make pino export BaseLogger again
|
|
29
27
|
interface CustomLogger extends FastifyBaseLogger {
|
|
30
28
|
customMethod(msg: string, ...args: unknown[]): void;
|
|
31
29
|
}
|
|
32
30
|
|
|
33
|
-
// // ToDo https://github.com/pinojs/pino/issues/1100
|
|
34
31
|
class CustomLoggerImpl implements CustomLogger {
|
|
35
32
|
level = 'info'
|
|
36
33
|
customMethod (msg: string, ...args: unknown[]) { console.log(msg, args) }
|
|
@@ -60,7 +57,6 @@ CustomLoggerImpl
|
|
|
60
57
|
>({ logger: customLogger })
|
|
61
58
|
|
|
62
59
|
expectType<CustomLoggerImpl>(serverWithCustomLogger.log)
|
|
63
|
-
*/
|
|
64
60
|
|
|
65
61
|
const serverWithPino = fastify<
|
|
66
62
|
Server,
|
|
@@ -213,6 +209,9 @@ const passPinoOption = fastify({
|
|
|
213
209
|
|
|
214
210
|
expectType<FastifyBaseLogger>(passPinoOption.log)
|
|
215
211
|
|
|
212
|
+
// FastifyLoggerInstance is deprecated
|
|
213
|
+
expectDeprecated({} as FastifyLoggerInstance)
|
|
214
|
+
|
|
216
215
|
const childParent = fastify().log
|
|
217
216
|
// we test different option variant here
|
|
218
217
|
expectType<FastifyLoggerInstance>(childParent.child({}, { level: 'info' }))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expectType, expectError } from 'tsd'
|
|
1
|
+
import { expectType, expectError, expectAssignable } from 'tsd'
|
|
2
2
|
import fastify, { RouteHandlerMethod, RouteHandler, RawRequestDefaultExpression, FastifyContext, FastifyContextConfig, FastifyRequest, FastifyReply } from '../../fastify'
|
|
3
3
|
import { RawServerDefault, RawReplyDefaultExpression, ContextConfigDefault } from '../../types/utils'
|
|
4
4
|
import { FastifyLoggerInstance } from '../../types/logger'
|
|
@@ -6,6 +6,8 @@ import { RouteGenericInterface } from '../../types/route'
|
|
|
6
6
|
import { FastifyInstance } from '../../types/instance'
|
|
7
7
|
import { Buffer } from 'buffer'
|
|
8
8
|
|
|
9
|
+
type DefaultSerializationFunction = (payload: {[key: string]: unknown}) => string
|
|
10
|
+
|
|
9
11
|
const getHandler: RouteHandlerMethod = function (_request, reply) {
|
|
10
12
|
expectType<RawReplyDefaultExpression>(reply.raw)
|
|
11
13
|
expectType<FastifyContext<ContextConfigDefault>>(reply.context)
|
|
@@ -19,7 +21,7 @@ const getHandler: RouteHandlerMethod = function (_request, reply) {
|
|
|
19
21
|
expectType<((payload?: unknown) => FastifyReply)>(reply.send)
|
|
20
22
|
expectType<(key: string, value: any) => FastifyReply>(reply.header)
|
|
21
23
|
expectType<(values: {[key: string]: any}) => FastifyReply>(reply.headers)
|
|
22
|
-
expectType<(key: string) => string | undefined>(reply.getHeader)
|
|
24
|
+
expectType<(key: string) => number | string | string[] | undefined>(reply.getHeader)
|
|
23
25
|
expectType<() => { [key: string]: number | string | string[] | undefined }>(reply.getHeaders)
|
|
24
26
|
expectType<(key: string) => void>(reply.removeHeader)
|
|
25
27
|
expectType<(key: string) => boolean>(reply.hasHeader)
|
|
@@ -32,6 +34,11 @@ const getHandler: RouteHandlerMethod = function (_request, reply) {
|
|
|
32
34
|
expectType<(payload: any) => string | ArrayBuffer | Buffer>(reply.serialize)
|
|
33
35
|
expectType<(fulfilled: () => void, rejected: (err: Error) => void) => void>(reply.then)
|
|
34
36
|
expectType<FastifyInstance>(reply.server)
|
|
37
|
+
expectAssignable<((httpStatus: string) => DefaultSerializationFunction)>(reply.getSerializationFunction)
|
|
38
|
+
expectAssignable<((schema: {[key: string]: unknown}) => DefaultSerializationFunction)>(reply.getSerializationFunction)
|
|
39
|
+
expectAssignable<((schema: {[key: string]: unknown}, httpStatus?: string) => DefaultSerializationFunction)>(reply.compileSerializationSchema)
|
|
40
|
+
expectAssignable<((input: {[key: string]: unknown}, schema: {[key: string]: unknown}, httpStatus?: string) => unknown)>(reply.serializeInput)
|
|
41
|
+
expectAssignable<((input: {[key: string]: unknown}, httpStatus: string) => unknown)>(reply.serializeInput)
|
|
35
42
|
}
|
|
36
43
|
|
|
37
44
|
interface ReplyPayload {
|
|
@@ -40,6 +47,14 @@ interface ReplyPayload {
|
|
|
40
47
|
};
|
|
41
48
|
}
|
|
42
49
|
|
|
50
|
+
interface ReplyUnion {
|
|
51
|
+
Reply: {
|
|
52
|
+
success: boolean;
|
|
53
|
+
} | {
|
|
54
|
+
error: string;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
43
58
|
const typedHandler: RouteHandler<ReplyPayload> = async (request, reply) => {
|
|
44
59
|
expectType<((payload?: ReplyPayload['Reply']) => FastifyReply<RawServerDefault, RawRequestDefaultExpression<RawServerDefault>, RawReplyDefaultExpression<RawServerDefault>, ReplyPayload>)>(reply.send)
|
|
45
60
|
}
|
|
@@ -53,9 +68,35 @@ server.get<ReplyPayload>('/get-generic-send', async function handler (request, r
|
|
|
53
68
|
server.get<ReplyPayload>('/get-generic-return', async function handler (request, reply) {
|
|
54
69
|
return { test: false }
|
|
55
70
|
})
|
|
56
|
-
expectError(server.get<ReplyPayload>('/get-generic-
|
|
71
|
+
expectError(server.get<ReplyPayload>('/get-generic-send-error', async function handler (request, reply) {
|
|
57
72
|
reply.send({ foo: 'bar' })
|
|
58
73
|
}))
|
|
59
74
|
expectError(server.get<ReplyPayload>('/get-generic-return-error', async function handler (request, reply) {
|
|
60
75
|
return { foo: 'bar' }
|
|
61
76
|
}))
|
|
77
|
+
server.get<ReplyUnion>('/get-generic-union-send', async function handler (request, reply) {
|
|
78
|
+
if (0 as number === 0) {
|
|
79
|
+
reply.send({ success: true })
|
|
80
|
+
} else {
|
|
81
|
+
reply.send({ error: 'error' })
|
|
82
|
+
}
|
|
83
|
+
})
|
|
84
|
+
server.get<ReplyUnion>('/get-generic-union-return', async function handler (request, reply) {
|
|
85
|
+
if (0 as number === 0) {
|
|
86
|
+
return { success: true }
|
|
87
|
+
} else {
|
|
88
|
+
return { error: 'error' }
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
expectError(server.get<ReplyUnion>('/get-generic-union-send-error-1', async function handler (request, reply) {
|
|
92
|
+
reply.send({ successes: true })
|
|
93
|
+
}))
|
|
94
|
+
expectError(server.get<ReplyUnion>('/get-generic-union-send-error-2', async function handler (request, reply) {
|
|
95
|
+
reply.send({ error: 500 })
|
|
96
|
+
}))
|
|
97
|
+
expectError(server.get<ReplyUnion>('/get-generic-union-return-error-1', async function handler (request, reply) {
|
|
98
|
+
return { successes: true }
|
|
99
|
+
}))
|
|
100
|
+
expectError(server.get<ReplyUnion>('/get-generic-union-return-error-2', async function handler (request, reply) {
|
|
101
|
+
return { error: 500 }
|
|
102
|
+
}))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { expectType } from 'tsd'
|
|
1
|
+
import { expectAssignable, expectType } from 'tsd'
|
|
2
2
|
import pino from 'pino'
|
|
3
3
|
import fastify, {
|
|
4
4
|
RouteHandler,
|
|
@@ -21,7 +21,6 @@ import { FastifyRequest } from '../../types/request'
|
|
|
21
21
|
import { FastifyReply } from '../../types/reply'
|
|
22
22
|
import { FastifyInstance } from '../../types/instance'
|
|
23
23
|
import { RouteGenericInterface } from '../../types/route'
|
|
24
|
-
import { ResolveFastifyReplyReturnType, ResolveFastifyRequestType } from '../../types/type-provider'
|
|
25
24
|
|
|
26
25
|
interface RequestBody {
|
|
27
26
|
content: string;
|
|
@@ -55,6 +54,9 @@ type CustomRequest = FastifyRequest<{
|
|
|
55
54
|
Headers: RequestHeaders;
|
|
56
55
|
}>
|
|
57
56
|
|
|
57
|
+
type HTTPRequestPart = 'body' | 'query' | 'querystring' | 'params' | 'headers'
|
|
58
|
+
type ExpectedGetValidationFunction = (input: {[key: string]: unknown}) => boolean
|
|
59
|
+
|
|
58
60
|
interface CustomLoggerInterface extends FastifyLoggerInstance {
|
|
59
61
|
foo: FastifyLogFn; // custom severity logger method
|
|
60
62
|
}
|
|
@@ -83,9 +85,13 @@ const getHandler: RouteHandler = function (request, _reply) {
|
|
|
83
85
|
expectType<RawRequestDefaultExpression['socket']>(request.socket)
|
|
84
86
|
expectType<Error & { validation: any; validationContext: string } | undefined>(request.validationError)
|
|
85
87
|
expectType<FastifyInstance>(request.server)
|
|
88
|
+
expectAssignable<(httpPart: HTTPRequestPart) => ExpectedGetValidationFunction>(request.getValidationFunction)
|
|
89
|
+
expectAssignable<(schema: {[key: string]: unknown}) => ExpectedGetValidationFunction>(request.getValidationFunction)
|
|
90
|
+
expectAssignable<(input: {[key: string]: unknown}, schema: {[key: string]: unknown}, httpPart?: HTTPRequestPart) => boolean>(request.validateInput)
|
|
91
|
+
expectAssignable<(input: {[key: string]: unknown}, httpPart?: HTTPRequestPart) => boolean>(request.validateInput)
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
const getHandlerWithCustomLogger: RouteHandlerMethod<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault,
|
|
94
|
+
const getHandlerWithCustomLogger: RouteHandlerMethod<RawServerDefault, RawRequestDefaultExpression, RawReplyDefaultExpression, RouteGenericInterface, ContextConfigDefault, FastifySchema, FastifyTypeProviderDefault, CustomLoggerInterface> = function (request, _reply) {
|
|
89
95
|
expectType<CustomLoggerInterface>(request.log)
|
|
90
96
|
}
|
|
91
97
|
|
|
@@ -128,17 +134,6 @@ server.put('/put', putHandler)
|
|
|
128
134
|
|
|
129
135
|
const customLogger: CustomLoggerInterface = {
|
|
130
136
|
level: 'info',
|
|
131
|
-
version: '5.0',
|
|
132
|
-
useOnlyCustomLevels: false,
|
|
133
|
-
useLevelLabels: false,
|
|
134
|
-
levels: { labels: [], values: {} },
|
|
135
|
-
eventNames: () => [],
|
|
136
|
-
listenerCount: (eventName: string | symbol) => 0,
|
|
137
|
-
bindings: () => ({}),
|
|
138
|
-
flush: () => () => {},
|
|
139
|
-
customLevels: { foo: 1 },
|
|
140
|
-
isLevelEnabled: () => false,
|
|
141
|
-
levelVal: 0,
|
|
142
137
|
silent: () => { },
|
|
143
138
|
info: () => { },
|
|
144
139
|
warn: () => { },
|
|
@@ -147,21 +142,7 @@ const customLogger: CustomLoggerInterface = {
|
|
|
147
142
|
trace: () => { },
|
|
148
143
|
debug: () => { },
|
|
149
144
|
foo: () => { }, // custom severity logger method
|
|
150
|
-
|
|
151
|
-
emit: (event, listener) => false,
|
|
152
|
-
off: (event, listener) => customLogger,
|
|
153
|
-
addListener: (event, listener) => customLogger,
|
|
154
|
-
prependListener: (event, listener) => customLogger,
|
|
155
|
-
prependOnceListener: (event, listener) => customLogger,
|
|
156
|
-
removeListener: (event, listener) => customLogger,
|
|
157
|
-
removeAllListeners: (event) => customLogger,
|
|
158
|
-
setMaxListeners: (n) => customLogger,
|
|
159
|
-
getMaxListeners: () => 0,
|
|
160
|
-
listeners: () => [],
|
|
161
|
-
rawListeners: () => [],
|
|
162
|
-
once: (event, listener) => customLogger,
|
|
163
|
-
child: () => customLogger as pino.Logger<never>,
|
|
164
|
-
setBindings: (bindings) => { }
|
|
145
|
+
child: () => customLogger as pino.Logger<never>
|
|
165
146
|
}
|
|
166
147
|
|
|
167
148
|
const serverWithCustomLogger = fastify({ logger: customLogger })
|
|
@@ -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
|
|
|
@@ -392,7 +391,9 @@ expectError(server.withTypeProvider<JsonSchemaToTsProvider>().get(
|
|
|
392
391
|
// https://github.com/fastify/fastify/issues/4088
|
|
393
392
|
expectError(server.withTypeProvider<JsonSchemaToTsProvider>().get('/', {
|
|
394
393
|
schema: {
|
|
395
|
-
response: {
|
|
394
|
+
response: {
|
|
395
|
+
200: { type: 'string' }
|
|
396
|
+
}
|
|
396
397
|
} as const
|
|
397
398
|
}, (_, res) => {
|
|
398
399
|
return { foo: 555 }
|
|
@@ -437,3 +438,74 @@ expectAssignable(server.withTypeProvider<JsonSchemaToTsProvider>().get<{Reply: b
|
|
|
437
438
|
return true
|
|
438
439
|
}
|
|
439
440
|
))
|
|
441
|
+
|
|
442
|
+
// -------------------------------------------------------------------
|
|
443
|
+
// FastifyPlugin: Auxiliary
|
|
444
|
+
// -------------------------------------------------------------------
|
|
445
|
+
|
|
446
|
+
interface AuxiliaryPluginProvider extends FastifyTypeProvider { output: 'plugin-auxiliary' }
|
|
447
|
+
|
|
448
|
+
// Auxiliary plugins may have varying server types per application. Recommendation would be to explicitly remap instance provider context within plugin if required.
|
|
449
|
+
function plugin<T extends FastifyInstance> (instance: T) {
|
|
450
|
+
expectAssignable(instance.withTypeProvider<AuxiliaryPluginProvider>().get(
|
|
451
|
+
'/',
|
|
452
|
+
{
|
|
453
|
+
schema: { body: null }
|
|
454
|
+
},
|
|
455
|
+
(req) => {
|
|
456
|
+
expectType<'plugin-auxiliary'>(req.body)
|
|
457
|
+
}
|
|
458
|
+
))
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
expectAssignable(server.withTypeProvider<AuxiliaryPluginProvider>().register(plugin).get(
|
|
462
|
+
'/',
|
|
463
|
+
{
|
|
464
|
+
schema: { body: null }
|
|
465
|
+
},
|
|
466
|
+
(req) => {
|
|
467
|
+
expectType<'plugin-auxiliary'>(req.body)
|
|
468
|
+
}
|
|
469
|
+
))
|
|
470
|
+
|
|
471
|
+
// -------------------------------------------------------------------
|
|
472
|
+
// Handlers: Inline
|
|
473
|
+
// -------------------------------------------------------------------
|
|
474
|
+
|
|
475
|
+
interface InlineHandlerProvider extends FastifyTypeProvider { output: 'handler-inline' }
|
|
476
|
+
|
|
477
|
+
// Inline handlers should infer for the request parameters (non-shared)
|
|
478
|
+
expectAssignable(server.withTypeProvider<InlineHandlerProvider>().get(
|
|
479
|
+
'/',
|
|
480
|
+
{
|
|
481
|
+
onRequest: (req, res) => {
|
|
482
|
+
expectType<'handler-inline'>(req.body)
|
|
483
|
+
},
|
|
484
|
+
schema: { body: null }
|
|
485
|
+
},
|
|
486
|
+
(req) => {
|
|
487
|
+
expectType<'handler-inline'>(req.body)
|
|
488
|
+
}
|
|
489
|
+
))
|
|
490
|
+
|
|
491
|
+
// -------------------------------------------------------------------
|
|
492
|
+
// Handlers: Auxiliary
|
|
493
|
+
// -------------------------------------------------------------------
|
|
494
|
+
|
|
495
|
+
interface AuxiliaryHandlerProvider extends FastifyTypeProvider { output: 'handler-auxiliary' }
|
|
496
|
+
|
|
497
|
+
// Auxiliary handlers are likely shared for multiple routes and thus should infer as unknown due to potential varying parameters
|
|
498
|
+
function auxiliaryHandler (request: FastifyRequest, reply: FastifyReply, done: HookHandlerDoneFunction): void {
|
|
499
|
+
expectType<unknown>(request.body)
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
expectAssignable(server.withTypeProvider<AuxiliaryHandlerProvider>().get(
|
|
503
|
+
'/',
|
|
504
|
+
{
|
|
505
|
+
onRequest: auxiliaryHandler,
|
|
506
|
+
schema: { body: null }
|
|
507
|
+
},
|
|
508
|
+
(req) => {
|
|
509
|
+
expectType<'handler-auxiliary'>(req.body)
|
|
510
|
+
}
|
|
511
|
+
))
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const t = require('tap')
|
|
4
|
+
const test = t.test
|
|
5
|
+
const sget = require('simple-get').concat
|
|
6
|
+
const fastify = require('..')()
|
|
7
|
+
|
|
8
|
+
test('can be created - unlock', t => {
|
|
9
|
+
t.plan(1)
|
|
10
|
+
try {
|
|
11
|
+
fastify.route({
|
|
12
|
+
method: 'UNLOCK',
|
|
13
|
+
url: '*',
|
|
14
|
+
handler: function (req, reply) {
|
|
15
|
+
reply.code(204).send()
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
t.pass()
|
|
19
|
+
} catch (e) {
|
|
20
|
+
t.fail()
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
fastify.listen({ port: 0 }, err => {
|
|
25
|
+
t.error(err)
|
|
26
|
+
t.teardown(() => { fastify.close() })
|
|
27
|
+
|
|
28
|
+
test('request - unlock', t => {
|
|
29
|
+
t.plan(2)
|
|
30
|
+
sget({
|
|
31
|
+
url: `http://localhost:${fastify.server.address().port}/test/a.txt`,
|
|
32
|
+
method: 'UNLOCK',
|
|
33
|
+
headers: {
|
|
34
|
+
'Lock-Token': 'urn:uuid:a515cfa4-5da4-22e1-f5b5-00a0451e6bf7'
|
|
35
|
+
}
|
|
36
|
+
}, (err, response, body) => {
|
|
37
|
+
t.error(err)
|
|
38
|
+
t.equal(response.statusCode, 204)
|
|
39
|
+
})
|
|
40
|
+
})
|
|
41
|
+
})
|
|
@@ -494,12 +494,17 @@ test('the custom error formatter context must be the server instance in options'
|
|
|
494
494
|
})
|
|
495
495
|
|
|
496
496
|
test('should call custom error formatter', t => {
|
|
497
|
-
t.plan(
|
|
497
|
+
t.plan(9)
|
|
498
498
|
|
|
499
499
|
const fastify = Fastify({
|
|
500
500
|
schemaErrorFormatter: (errors, dataVar) => {
|
|
501
501
|
t.equal(errors.length, 1)
|
|
502
502
|
t.equal(errors[0].message, "must have required property 'name'")
|
|
503
|
+
t.equal(errors[0].keyword, 'required')
|
|
504
|
+
t.equal(errors[0].schemaPath, '#/required')
|
|
505
|
+
t.same(errors[0].params, {
|
|
506
|
+
missingProperty: 'name'
|
|
507
|
+
})
|
|
503
508
|
t.equal(dataVar, 'body')
|
|
504
509
|
return new Error('my error')
|
|
505
510
|
}
|
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>;
|