fastify 3.27.3 → 4.0.0-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.taprc +3 -0
- package/README.md +7 -7
- package/build/build-error-serializer.js +27 -0
- package/build/build-validation.js +47 -35
- package/docs/Guides/Database.md +320 -0
- package/docs/Guides/Getting-Started.md +7 -7
- package/docs/Guides/Plugins-Guide.md +1 -1
- package/docs/Guides/Serverless.md +3 -3
- package/docs/Guides/Testing.md +2 -2
- package/docs/Migration-Guide-V4.md +12 -0
- package/docs/Reference/ContentTypeParser.md +4 -0
- package/docs/Reference/Decorators.md +2 -2
- package/docs/Reference/Encapsulation.md +2 -2
- package/docs/Reference/Errors.md +51 -6
- package/docs/Reference/HTTP2.md +3 -3
- package/docs/Reference/Hooks.md +4 -7
- package/docs/Reference/LTS.md +5 -4
- package/docs/Reference/Plugins.md +3 -3
- package/docs/Reference/Reply.md +23 -22
- package/docs/Reference/Request.md +1 -3
- package/docs/Reference/Routes.md +22 -15
- package/docs/Reference/Server.md +69 -119
- package/docs/Reference/TypeScript.md +20 -22
- package/docs/Reference/Validation-and-Serialization.md +30 -55
- package/docs/Type-Providers.md +257 -0
- package/examples/asyncawait.js +1 -1
- package/examples/benchmark/hooks-benchmark-async-await.js +1 -1
- package/examples/benchmark/hooks-benchmark.js +1 -1
- package/examples/benchmark/simple.js +1 -1
- package/examples/hooks.js +2 -2
- package/examples/http2.js +1 -1
- package/examples/https.js +1 -1
- package/examples/parser.js +1 -1
- package/examples/route-prefix.js +1 -1
- package/examples/shared-schema.js +1 -1
- package/examples/simple-stream.js +18 -0
- package/examples/simple.js +1 -1
- package/examples/simple.mjs +1 -1
- package/examples/typescript-server.ts +1 -1
- package/examples/use-plugin.js +1 -1
- package/fastify.d.ts +34 -22
- package/fastify.js +40 -36
- package/lib/configValidator.js +902 -1023
- package/lib/contentTypeParser.js +6 -16
- package/lib/context.js +36 -10
- package/lib/decorate.js +3 -1
- package/lib/error-handler.js +158 -0
- package/lib/error-serializer.js +257 -0
- package/lib/errors.js +43 -9
- package/lib/fourOhFour.js +31 -20
- package/lib/handleRequest.js +10 -13
- package/lib/hooks.js +14 -9
- package/lib/pluginOverride.js +0 -3
- package/lib/pluginUtils.js +3 -2
- package/lib/reply.js +29 -158
- package/lib/request.js +13 -10
- package/lib/route.js +131 -138
- package/lib/schema-controller.js +2 -2
- package/lib/schemas.js +27 -1
- package/lib/server.js +241 -116
- package/lib/symbols.js +4 -3
- package/lib/validation.js +2 -1
- package/lib/warnings.js +4 -12
- package/lib/wrapThenable.js +4 -11
- package/package.json +37 -39
- package/test/404s.test.js +258 -125
- package/test/500s.test.js +3 -3
- package/test/als.test.js +1 -1
- package/test/async-await.test.js +20 -76
- package/test/bodyLimit.test.js +1 -1
- package/test/build-certificate.js +6 -7
- package/test/case-insensitive.test.js +4 -4
- package/test/close-pipelining.test.js +2 -2
- package/test/close.test.js +11 -11
- package/test/content-parser.test.js +32 -0
- package/test/context-config.test.js +52 -0
- package/test/custom-http-server.test.js +14 -7
- package/test/custom-parser-async.test.js +1 -66
- package/test/custom-parser.test.js +92 -159
- package/test/custom-querystring-parser.test.js +3 -3
- package/test/decorator.test.js +11 -13
- package/test/delete.test.js +6 -6
- package/test/encapsulated-error-handler.test.js +50 -0
- package/test/esm/index.test.js +0 -14
- package/test/fastify-instance.test.js +4 -4
- package/test/fluent-schema.test.js +4 -4
- package/test/genReqId.test.js +1 -1
- package/test/get.test.js +4 -4
- package/test/handler-context.test.js +2 -2
- package/test/head.test.js +1 -1
- package/test/helper.js +19 -4
- package/test/hooks-async.test.js +15 -48
- package/test/hooks.on-ready.test.js +10 -5
- package/test/hooks.test.js +78 -119
- package/test/http2/closing.test.js +10 -16
- package/test/http2/constraint.test.js +1 -1
- package/test/http2/head.test.js +1 -1
- package/test/http2/plain.test.js +1 -1
- package/test/http2/secure-with-fallback.test.js +1 -1
- package/test/http2/secure.test.js +1 -1
- package/test/http2/unknown-http-method.test.js +4 -10
- package/test/https/custom-https-server.test.js +12 -6
- package/test/https/https.test.js +1 -1
- package/test/input-validation.js +3 -3
- package/test/internals/handleRequest.test.js +6 -43
- package/test/internals/initialConfig.test.js +41 -12
- package/test/internals/logger.test.js +2 -2
- package/test/internals/reply.test.js +281 -40
- package/test/internals/request.test.js +13 -7
- package/test/internals/server.test.js +88 -0
- package/test/listen.deprecated.test.js +202 -0
- package/test/listen.test.js +118 -150
- package/test/logger.test.js +82 -42
- package/test/maxRequestsPerSocket.test.js +8 -6
- package/test/middleware.test.js +2 -25
- package/test/nullable-validation.test.js +53 -16
- package/test/output-validation.test.js +1 -1
- package/test/plugin.test.js +47 -21
- package/test/pretty-print.test.js +22 -10
- package/test/promises.test.js +1 -1
- package/test/proto-poisoning.test.js +6 -6
- package/test/register.test.js +3 -3
- package/test/reply-error.test.js +126 -15
- package/test/request-error.test.js +3 -6
- package/test/route-hooks.test.js +18 -18
- package/test/route-prefix.test.js +2 -1
- package/test/route.test.js +206 -22
- package/test/router-options.test.js +2 -2
- package/test/schema-examples.test.js +11 -5
- package/test/schema-feature.test.js +25 -20
- package/test/schema-serialization.test.js +9 -9
- package/test/schema-special-usage.test.js +5 -153
- package/test/schema-validation.test.js +9 -9
- package/test/skip-reply-send.test.js +2 -2
- package/test/stream.test.js +82 -23
- package/test/throw.test.js +8 -5
- package/test/trust-proxy.test.js +6 -6
- package/test/type-provider.test.js +20 -0
- package/test/types/fastify.test-d.ts +10 -18
- package/test/types/import.js +2 -0
- package/test/types/import.ts +1 -0
- package/test/types/instance.test-d.ts +68 -17
- package/test/types/logger.test-d.ts +44 -15
- package/test/types/reply.test-d.ts +2 -1
- package/test/types/route.test-d.ts +8 -2
- package/test/types/schema.test-d.ts +2 -39
- package/test/types/type-provider.test-d.ts +417 -0
- package/test/url-rewriting.test.js +3 -3
- package/test/validation-error-handling.test.js +8 -8
- package/test/versioned-routes.test.js +30 -18
- package/test/wrapThenable.test.js +7 -6
- package/types/content-type-parser.d.ts +17 -8
- package/types/hooks.d.ts +102 -59
- package/types/instance.d.ts +244 -118
- package/types/logger.d.ts +18 -104
- package/types/plugin.d.ts +10 -4
- package/types/reply.d.ts +18 -12
- package/types/request.d.ts +10 -5
- package/types/route.d.ts +42 -31
- package/types/schema.d.ts +1 -1
- package/types/type-provider.d.ts +99 -0
- package/types/utils.d.ts +1 -1
- package/lib/schema-compilers.js +0 -12
- package/test/emit-warning.test.js +0 -166
package/types/instance.d.ts
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { FastifyError } from 'fastify-error'
|
|
2
|
+
import { CallbackFunc as LightMyRequestCallback, Chain as LightMyRequestChain, InjectOptions, Response as LightMyRequestResponse } from 'light-my-request'
|
|
3
|
+
import { AddContentTypeParser, ConstructorAction, FastifyBodyParser, getDefaultJsonParser, hasContentTypeParser, ProtoAction, removeAllContentTypeParsers, removeContentTypeParser } from './content-type-parser'
|
|
4
|
+
import { onCloseAsyncHookHandler, onCloseHookHandler, onErrorAsyncHookHandler, onErrorHookHandler, onReadyAsyncHookHandler, onReadyHookHandler, onRegisterHookHandler, onRequestAsyncHookHandler, onRequestHookHandler, onResponseAsyncHookHandler, onResponseHookHandler, onRouteHookHandler, onSendAsyncHookHandler, onSendHookHandler, onTimeoutAsyncHookHandler, onTimeoutHookHandler, preHandlerAsyncHookHandler, preHandlerHookHandler, preParsingAsyncHookHandler, preParsingHookHandler, preSerializationAsyncHookHandler, preSerializationHookHandler, preValidationAsyncHookHandler, preValidationHookHandler } from './hooks'
|
|
5
|
+
import { FastifyLoggerInstance } from './logger'
|
|
6
|
+
import { FastifyRegister } from './register'
|
|
7
|
+
import { FastifyReply } from './reply'
|
|
8
|
+
import { FastifyRequest } from './request'
|
|
9
|
+
import { DefaultRoute, RouteGenericInterface, RouteOptions, RouteShorthandMethod } from './route'
|
|
3
10
|
import {
|
|
4
11
|
FastifySchema,
|
|
5
12
|
FastifySchemaCompiler,
|
|
13
|
+
FastifySchemaControllerOptions,
|
|
6
14
|
FastifySchemaValidationError,
|
|
7
|
-
FastifySerializerCompiler
|
|
8
|
-
FastifySchemaControllerOptions
|
|
15
|
+
FastifySerializerCompiler
|
|
9
16
|
} from './schema'
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { FastifyRegister } from './register'
|
|
13
|
-
import { onRequestHookHandler, preParsingHookHandler, onSendHookHandler, preValidationHookHandler, preHandlerHookHandler, preSerializationHookHandler, onResponseHookHandler, onErrorHookHandler, onRouteHookHandler, onRegisterHookHandler, onCloseHookHandler, onCloseAsyncHookHandler, onReadyHookHandler, onTimeoutHookHandler, preParsingAsyncHookHandler, preValidationAsyncHookHandler, preHandlerAsyncHookHandler, preSerializationAsyncHookHandler, onSendAsyncHookHandler, onResponseAsyncHookHandler, onTimeoutAsyncHookHandler, onErrorAsyncHookHandler, onReadyAsyncHookHandler, onRequestAsyncHookHandler } from './hooks'
|
|
14
|
-
import { FastifyRequest } from './request'
|
|
15
|
-
import { FastifyReply } from './reply'
|
|
16
|
-
import { FastifyError } from 'fastify-error'
|
|
17
|
-
import { AddContentTypeParser, hasContentTypeParser, getDefaultJsonParser, ProtoAction, ConstructorAction, FastifyBodyParser, removeContentTypeParser, removeAllContentTypeParsers } from './content-type-parser'
|
|
17
|
+
import { FastifyTypeProvider, FastifyTypeProviderDefault } from './type-provider'
|
|
18
|
+
import { ContextConfigDefault, RawReplyDefaultExpression, RawRequestDefaultExpression, RawServerBase, RawServerDefault } from './utils'
|
|
18
19
|
|
|
19
20
|
export interface PrintRoutesOptions {
|
|
20
21
|
includeMeta?: boolean | (string | symbol)[]
|
|
@@ -22,6 +23,8 @@ export interface PrintRoutesOptions {
|
|
|
22
23
|
includeHooks?: boolean
|
|
23
24
|
}
|
|
24
25
|
|
|
26
|
+
type NotInInterface<Key, _Interface> = Key extends keyof _Interface ? never : Key
|
|
27
|
+
|
|
25
28
|
/**
|
|
26
29
|
* Fastify server instance. Returned by the core `fastify()` method.
|
|
27
30
|
*/
|
|
@@ -29,19 +32,22 @@ export interface FastifyInstance<
|
|
|
29
32
|
RawServer extends RawServerBase = RawServerDefault,
|
|
30
33
|
RawRequest extends RawRequestDefaultExpression<RawServer> = RawRequestDefaultExpression<RawServer>,
|
|
31
34
|
RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
|
|
32
|
-
Logger = FastifyLoggerInstance
|
|
35
|
+
Logger = FastifyLoggerInstance,
|
|
36
|
+
TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
|
|
33
37
|
> {
|
|
34
38
|
server: RawServer;
|
|
35
39
|
prefix: string;
|
|
36
40
|
version: string;
|
|
37
41
|
log: Logger;
|
|
38
42
|
|
|
39
|
-
|
|
43
|
+
withTypeProvider<Provider extends FastifyTypeProvider>(): FastifyInstance<RawServer, RawRequest, RawReply, Logger, Provider>;
|
|
44
|
+
|
|
45
|
+
addSchema(schema: unknown): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
40
46
|
getSchema(schemaId: string): unknown;
|
|
41
47
|
getSchemas(): Record<string, unknown>;
|
|
42
48
|
|
|
43
|
-
after(): FastifyInstance<RawServer, RawRequest, RawReply, Logger> & PromiseLike<undefined>;
|
|
44
|
-
after(afterListener: (err: Error) => void): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
49
|
+
after(): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider> & PromiseLike<undefined>;
|
|
50
|
+
after(afterListener: (err: Error) => void): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
45
51
|
|
|
46
52
|
close(): Promise<undefined>;
|
|
47
53
|
close(closeListener: () => void): undefined;
|
|
@@ -49,24 +55,24 @@ export interface FastifyInstance<
|
|
|
49
55
|
// should be able to define something useful with the decorator getter/setter pattern using Generics to enforce the users function returns what they expect it to
|
|
50
56
|
decorate<T>(property: string | symbol,
|
|
51
57
|
value: T extends (...args: any[]) => any
|
|
52
|
-
? (this: FastifyInstance<RawServer, RawRequest, RawReply, Logger>, ...args: Parameters<T>) => ReturnType<T>
|
|
58
|
+
? (this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, ...args: Parameters<T>) => ReturnType<T>
|
|
53
59
|
: T,
|
|
54
60
|
dependencies?: string[]
|
|
55
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
61
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
56
62
|
|
|
57
63
|
decorateRequest<T>(property: string | symbol,
|
|
58
64
|
value: T extends (...args: any[]) => any
|
|
59
65
|
? (this: FastifyRequest, ...args: Parameters<T>) => ReturnType<T>
|
|
60
66
|
: T,
|
|
61
67
|
dependencies?: string[]
|
|
62
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
68
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
63
69
|
|
|
64
70
|
decorateReply<T>(property: string | symbol,
|
|
65
71
|
value: T extends (...args: any[]) => any
|
|
66
72
|
? (this: FastifyReply, ...args: Parameters<T>) => ReturnType<T>
|
|
67
73
|
: T,
|
|
68
74
|
dependencies?: string[]
|
|
69
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
75
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
70
76
|
|
|
71
77
|
hasDecorator(decorator: string | symbol): boolean;
|
|
72
78
|
hasRequestDecorator(decorator: string | symbol): boolean;
|
|
@@ -76,17 +82,123 @@ export interface FastifyInstance<
|
|
|
76
82
|
inject(opts: InjectOptions | string): Promise<LightMyRequestResponse>;
|
|
77
83
|
inject(): LightMyRequestChain;
|
|
78
84
|
|
|
85
|
+
listen(opts: {
|
|
86
|
+
/**
|
|
87
|
+
* Default to `0` (picks the first available open port).
|
|
88
|
+
*/
|
|
89
|
+
port?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Default to `localhost`.
|
|
92
|
+
*/
|
|
93
|
+
host?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Will be ignored if `port` is specified.
|
|
96
|
+
* @see [Identifying paths for IPC connections](https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections).
|
|
97
|
+
*/
|
|
98
|
+
path?: string;
|
|
99
|
+
/**
|
|
100
|
+
* Specify the maximum length of the queue of pending connections.
|
|
101
|
+
* The actual length will be determined by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux.
|
|
102
|
+
* Default to `511`.
|
|
103
|
+
*/
|
|
104
|
+
backlog?: number;
|
|
105
|
+
/**
|
|
106
|
+
* Default to `false`.
|
|
107
|
+
*/
|
|
108
|
+
exclusive?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* For IPC servers makes the pipe readable for all users.
|
|
111
|
+
* Default to `false`.
|
|
112
|
+
*/
|
|
113
|
+
readableAll?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* For IPC servers makes the pipe writable for all users.
|
|
116
|
+
* Default to `false`.
|
|
117
|
+
*/
|
|
118
|
+
writableAll?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound.
|
|
121
|
+
* Default to `false`.
|
|
122
|
+
*/
|
|
123
|
+
ipv6Only?: boolean;
|
|
124
|
+
/**
|
|
125
|
+
* An AbortSignal that may be used to close a listening server.
|
|
126
|
+
* @since This option is available only in Node.js v15.6.0 and greater
|
|
127
|
+
*/
|
|
128
|
+
signal?: AbortSignal;
|
|
129
|
+
}, callback: (err: Error|null, address: string) => void): void;
|
|
130
|
+
listen(opts?: {
|
|
131
|
+
/**
|
|
132
|
+
* Default to `0` (picks the first available open port).
|
|
133
|
+
*/
|
|
134
|
+
port?: number;
|
|
135
|
+
/**
|
|
136
|
+
* Default to `localhost`.
|
|
137
|
+
*/
|
|
138
|
+
host?: string;
|
|
139
|
+
/**
|
|
140
|
+
* Will be ignored if `port` is specified.
|
|
141
|
+
* @see [Identifying paths for IPC connections](https://nodejs.org/api/net.html#identifying-paths-for-ipc-connections).
|
|
142
|
+
*/
|
|
143
|
+
path?: string;
|
|
144
|
+
/**
|
|
145
|
+
* Specify the maximum length of the queue of pending connections.
|
|
146
|
+
* The actual length will be determined by the OS through sysctl settings such as `tcp_max_syn_backlog` and `somaxconn` on Linux.
|
|
147
|
+
* Default to `511`.
|
|
148
|
+
*/
|
|
149
|
+
backlog?: number;
|
|
150
|
+
/**
|
|
151
|
+
* Default to `false`.
|
|
152
|
+
*/
|
|
153
|
+
exclusive?: boolean;
|
|
154
|
+
/**
|
|
155
|
+
* For IPC servers makes the pipe readable for all users.
|
|
156
|
+
* Default to `false`.
|
|
157
|
+
*/
|
|
158
|
+
readableAll?: boolean;
|
|
159
|
+
/**
|
|
160
|
+
* For IPC servers makes the pipe writable for all users.
|
|
161
|
+
* Default to `false`.
|
|
162
|
+
*/
|
|
163
|
+
writableAll?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* For TCP servers, setting `ipv6Only` to `true` will disable dual-stack support, i.e., binding to host `::` won't make `0.0.0.0` be bound.
|
|
166
|
+
* Default to `false`.
|
|
167
|
+
*/
|
|
168
|
+
ipv6Only?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* An AbortSignal that may be used to close a listening server.
|
|
171
|
+
* @since This option is available only in Node.js v15.6.0 and greater
|
|
172
|
+
*/
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}): Promise<string>;
|
|
175
|
+
listen(callback: (err: Error | null, address: string) => void): void;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
|
|
179
|
+
* @see https://github.com/fastify/fastify/pull/3712
|
|
180
|
+
*/
|
|
79
181
|
listen(port: number | string, address: string, backlog: number, callback: (err: Error|null, address: string) => void): void;
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
|
|
184
|
+
* @see https://github.com/fastify/fastify/pull/3712
|
|
185
|
+
*/
|
|
80
186
|
listen(port: number | string, address: string, callback: (err: Error|null, address: string) => void): void;
|
|
187
|
+
/**
|
|
188
|
+
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject, callback)` instead. The variadic signature will be removed in `fastify@5`
|
|
189
|
+
* @see https://github.com/fastify/fastify/pull/3712
|
|
190
|
+
*/
|
|
81
191
|
listen(port: number | string, callback: (err: Error|null, address: string) => void): void;
|
|
192
|
+
/**
|
|
193
|
+
* @deprecated Variadic listen method is deprecated. Please use `.listen(optionsObject)` instead. The variadic signature will be removed in `fastify@5`
|
|
194
|
+
* @see https://github.com/fastify/fastify/pull/3712
|
|
195
|
+
*/
|
|
82
196
|
listen(port: number | string, address?: string, backlog?: number): Promise<string>;
|
|
83
|
-
listen(opts: { port: number; host?: string; backlog?: number }, callback: (err: Error|null, address: string) => void): void;
|
|
84
|
-
listen(opts: { port: number; host?: string; backlog?: number }): Promise<string>;
|
|
85
197
|
|
|
86
|
-
ready(): FastifyInstance<RawServer, RawRequest, RawReply> & PromiseLike<undefined>;
|
|
87
|
-
ready(readyListener: (err: Error) => void): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
198
|
+
ready(): FastifyInstance<RawServer, RawRequest, RawReply, FastifyLoggerInstance, TypeProvider> & PromiseLike<undefined>;
|
|
199
|
+
ready(readyListener: (err: Error) => void): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
88
200
|
|
|
89
|
-
register: FastifyRegister<FastifyInstance<RawServer, RawRequest, RawReply, Logger> & PromiseLike<undefined>>;
|
|
201
|
+
register: FastifyRegister<FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider> & PromiseLike<undefined>>;
|
|
90
202
|
|
|
91
203
|
routing(req: RawRequest, res: RawReply): void;
|
|
92
204
|
getDefaultRoute: DefaultRoute<RawRequest, RawReply>;
|
|
@@ -96,16 +208,16 @@ export interface FastifyInstance<
|
|
|
96
208
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
97
209
|
ContextConfig = ContextConfigDefault,
|
|
98
210
|
SchemaCompiler = FastifySchema,
|
|
99
|
-
>(opts: RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler>): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
211
|
+
>(opts: RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
100
212
|
|
|
101
|
-
get: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
102
|
-
head: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
103
|
-
post: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
104
|
-
put: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
105
|
-
delete: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
106
|
-
options: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
107
|
-
patch: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
108
|
-
all: RouteShorthandMethod<RawServer, RawRequest, RawReply>;
|
|
213
|
+
get: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
214
|
+
head: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
215
|
+
post: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
216
|
+
put: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
217
|
+
delete: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
218
|
+
options: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
219
|
+
patch: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
220
|
+
all: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
|
|
109
221
|
|
|
110
222
|
// addHook: overloads
|
|
111
223
|
|
|
@@ -117,19 +229,21 @@ export interface FastifyInstance<
|
|
|
117
229
|
*/
|
|
118
230
|
addHook<
|
|
119
231
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
120
|
-
ContextConfig = ContextConfigDefault
|
|
232
|
+
ContextConfig = ContextConfigDefault,
|
|
233
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
121
234
|
>(
|
|
122
235
|
name: 'onRequest',
|
|
123
|
-
hook: onRequestHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
124
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
236
|
+
hook: onRequestHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
237
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
125
238
|
|
|
126
239
|
addHook<
|
|
127
240
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
128
|
-
ContextConfig = ContextConfigDefault
|
|
241
|
+
ContextConfig = ContextConfigDefault,
|
|
242
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
129
243
|
>(
|
|
130
244
|
name: 'onRequest',
|
|
131
|
-
hook: onRequestAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
132
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
245
|
+
hook: onRequestAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
246
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
133
247
|
|
|
134
248
|
/**
|
|
135
249
|
* `preParsing` is the second hook to be executed in the request lifecycle. The previous hook was `onRequest`, the next hook will be `preValidation`.
|
|
@@ -137,57 +251,63 @@ export interface FastifyInstance<
|
|
|
137
251
|
*/
|
|
138
252
|
addHook<
|
|
139
253
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
140
|
-
ContextConfig = ContextConfigDefault
|
|
254
|
+
ContextConfig = ContextConfigDefault,
|
|
255
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
141
256
|
>(
|
|
142
257
|
name: 'preParsing',
|
|
143
|
-
hook: preParsingHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
144
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
258
|
+
hook: preParsingHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
259
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
145
260
|
|
|
146
261
|
addHook<
|
|
147
262
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
148
|
-
ContextConfig = ContextConfigDefault
|
|
263
|
+
ContextConfig = ContextConfigDefault,
|
|
264
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
149
265
|
>(
|
|
150
266
|
name: 'preParsing',
|
|
151
|
-
hook: preParsingAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
152
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
267
|
+
hook: preParsingAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
268
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
153
269
|
|
|
154
270
|
/**
|
|
155
271
|
* `preValidation` is the third hook to be executed in the request lifecycle. The previous hook was `preParsing`, the next hook will be `preHandler`.
|
|
156
272
|
*/
|
|
157
273
|
addHook<
|
|
158
274
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
159
|
-
ContextConfig = ContextConfigDefault
|
|
275
|
+
ContextConfig = ContextConfigDefault,
|
|
276
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
160
277
|
>(
|
|
161
278
|
name: 'preValidation',
|
|
162
|
-
hook: preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
163
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
279
|
+
hook: preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
280
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
164
281
|
|
|
165
282
|
addHook<
|
|
166
283
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
167
|
-
ContextConfig = ContextConfigDefault
|
|
284
|
+
ContextConfig = ContextConfigDefault,
|
|
285
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
168
286
|
>(
|
|
169
287
|
name: 'preValidation',
|
|
170
|
-
hook: preValidationAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
171
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
288
|
+
hook: preValidationAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
289
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
172
290
|
|
|
173
291
|
/**
|
|
174
292
|
* `preHandler` is the fourth hook to be executed in the request lifecycle. The previous hook was `preValidation`, the next hook will be `preSerialization`.
|
|
175
293
|
*/
|
|
176
294
|
addHook<
|
|
177
295
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
178
|
-
ContextConfig = ContextConfigDefault
|
|
296
|
+
ContextConfig = ContextConfigDefault,
|
|
297
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
179
298
|
>(
|
|
180
299
|
name: 'preHandler',
|
|
181
|
-
hook: preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
182
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
300
|
+
hook: preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
301
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
183
302
|
|
|
184
303
|
addHook<
|
|
185
304
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
186
|
-
ContextConfig = ContextConfigDefault
|
|
305
|
+
ContextConfig = ContextConfigDefault,
|
|
306
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
187
307
|
>(
|
|
188
308
|
name: 'preHandler',
|
|
189
|
-
hook: preHandlerAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
190
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
309
|
+
hook: preHandlerAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
310
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
191
311
|
|
|
192
312
|
/**
|
|
193
313
|
* `preSerialization` is the fifth hook to be executed in the request lifecycle. The previous hook was `preHandler`, the next hook will be `onSend`.
|
|
@@ -196,20 +316,22 @@ export interface FastifyInstance<
|
|
|
196
316
|
addHook<
|
|
197
317
|
PreSerializationPayload = unknown,
|
|
198
318
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
199
|
-
ContextConfig = ContextConfigDefault
|
|
319
|
+
ContextConfig = ContextConfigDefault,
|
|
320
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
200
321
|
>(
|
|
201
322
|
name: 'preSerialization',
|
|
202
|
-
hook: preSerializationHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
203
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
323
|
+
hook: preSerializationHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
324
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
204
325
|
|
|
205
326
|
addHook<
|
|
206
327
|
PreSerializationPayload = unknown,
|
|
207
328
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
208
|
-
ContextConfig = ContextConfigDefault
|
|
329
|
+
ContextConfig = ContextConfigDefault,
|
|
330
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
209
331
|
>(
|
|
210
332
|
name: 'preSerialization',
|
|
211
|
-
hook: preSerializationAsyncHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
212
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
333
|
+
hook: preSerializationAsyncHookHandler<PreSerializationPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
334
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
213
335
|
|
|
214
336
|
/**
|
|
215
337
|
* You can change the payload with the `onSend` hook. It is the sixth hook to be executed in the request lifecycle. The previous hook was `preSerialization`, the next hook will be `onResponse`.
|
|
@@ -218,20 +340,22 @@ export interface FastifyInstance<
|
|
|
218
340
|
addHook<
|
|
219
341
|
OnSendPayload = unknown,
|
|
220
342
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
221
|
-
ContextConfig = ContextConfigDefault
|
|
343
|
+
ContextConfig = ContextConfigDefault,
|
|
344
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
222
345
|
>(
|
|
223
346
|
name: 'onSend',
|
|
224
|
-
hook: onSendHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
225
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
347
|
+
hook: onSendHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
348
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
226
349
|
|
|
227
350
|
addHook<
|
|
228
351
|
OnSendPayload = unknown,
|
|
229
352
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
230
|
-
ContextConfig = ContextConfigDefault
|
|
353
|
+
ContextConfig = ContextConfigDefault,
|
|
354
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
231
355
|
>(
|
|
232
356
|
name: 'onSend',
|
|
233
|
-
hook: onSendAsyncHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
234
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
357
|
+
hook: onSendAsyncHookHandler<OnSendPayload, RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
358
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
235
359
|
|
|
236
360
|
/**
|
|
237
361
|
* `onResponse` is the seventh and last hook in the request hook lifecycle. The previous hook was `onSend`, there is no next hook.
|
|
@@ -239,19 +363,21 @@ export interface FastifyInstance<
|
|
|
239
363
|
*/
|
|
240
364
|
addHook<
|
|
241
365
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
242
|
-
ContextConfig = ContextConfigDefault
|
|
366
|
+
ContextConfig = ContextConfigDefault,
|
|
367
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
243
368
|
>(
|
|
244
369
|
name: 'onResponse',
|
|
245
|
-
hook: onResponseHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
246
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
370
|
+
hook: onResponseHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
371
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
247
372
|
|
|
248
373
|
addHook<
|
|
249
374
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
250
|
-
ContextConfig = ContextConfigDefault
|
|
375
|
+
ContextConfig = ContextConfigDefault,
|
|
376
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
251
377
|
>(
|
|
252
378
|
name: 'onResponse',
|
|
253
|
-
hook: onResponseAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
254
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
379
|
+
hook: onResponseAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
380
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
255
381
|
|
|
256
382
|
/**
|
|
257
383
|
* `onTimeout` is useful if you need to monitor the request timed out in your service. (if the `connectionTimeout` property is set on the fastify instance)
|
|
@@ -259,19 +385,21 @@ export interface FastifyInstance<
|
|
|
259
385
|
*/
|
|
260
386
|
addHook<
|
|
261
387
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
262
|
-
ContextConfig = ContextConfigDefault
|
|
388
|
+
ContextConfig = ContextConfigDefault,
|
|
389
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
263
390
|
>(
|
|
264
391
|
name: 'onTimeout',
|
|
265
|
-
hook: onTimeoutHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
266
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
392
|
+
hook: onTimeoutHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
393
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
267
394
|
|
|
268
395
|
addHook<
|
|
269
396
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
270
|
-
ContextConfig = ContextConfigDefault
|
|
397
|
+
ContextConfig = ContextConfigDefault,
|
|
398
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
271
399
|
>(
|
|
272
400
|
name: 'onTimeout',
|
|
273
|
-
hook: onTimeoutAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
274
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
401
|
+
hook: onTimeoutAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
402
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
275
403
|
|
|
276
404
|
/**
|
|
277
405
|
* This hook is useful if you need to do some custom error logging or add some specific header in case of error.
|
|
@@ -281,19 +409,21 @@ export interface FastifyInstance<
|
|
|
281
409
|
*/
|
|
282
410
|
addHook<
|
|
283
411
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
284
|
-
ContextConfig = ContextConfigDefault
|
|
412
|
+
ContextConfig = ContextConfigDefault,
|
|
413
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
285
414
|
>(
|
|
286
415
|
name: 'onError',
|
|
287
|
-
hook: onErrorHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
288
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
416
|
+
hook: onErrorHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, TypeProvider>
|
|
417
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
289
418
|
|
|
290
419
|
addHook<
|
|
291
420
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
292
|
-
ContextConfig = ContextConfigDefault
|
|
421
|
+
ContextConfig = ContextConfigDefault,
|
|
422
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
293
423
|
>(
|
|
294
424
|
name: 'onError',
|
|
295
|
-
hook: onErrorAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
296
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
425
|
+
hook: onErrorAsyncHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, FastifyError, SchemaCompiler, TypeProvider>
|
|
426
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
297
427
|
|
|
298
428
|
// Application addHooks
|
|
299
429
|
|
|
@@ -302,11 +432,12 @@ export interface FastifyInstance<
|
|
|
302
432
|
*/
|
|
303
433
|
addHook<
|
|
304
434
|
RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
|
|
305
|
-
ContextConfig = ContextConfigDefault
|
|
435
|
+
ContextConfig = ContextConfigDefault,
|
|
436
|
+
SchemaCompiler extends FastifySchema = FastifySchema
|
|
306
437
|
>(
|
|
307
438
|
name: 'onRoute',
|
|
308
|
-
hook: onRouteHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>
|
|
309
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
439
|
+
hook: onRouteHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>
|
|
440
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
310
441
|
|
|
311
442
|
/**
|
|
312
443
|
* Triggered when a new plugin is registered and a new encapsulation context is created. The hook will be executed before the registered code.
|
|
@@ -315,8 +446,8 @@ export interface FastifyInstance<
|
|
|
315
446
|
*/
|
|
316
447
|
addHook(
|
|
317
448
|
name: 'onRegister',
|
|
318
|
-
hook: onRegisterHookHandler<RawServer, RawRequest, RawReply, Logger>
|
|
319
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
449
|
+
hook: onRegisterHookHandler<RawServer, RawRequest, RawReply, Logger, TypeProvider>
|
|
450
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
320
451
|
|
|
321
452
|
/**
|
|
322
453
|
* Triggered when fastify.listen() or fastify.ready() is invoked to start the server. It is useful when plugins need a "ready" event, for example to load data before the server start listening for requests.
|
|
@@ -324,20 +455,20 @@ export interface FastifyInstance<
|
|
|
324
455
|
addHook(
|
|
325
456
|
name: 'onReady',
|
|
326
457
|
hook: onReadyHookHandler
|
|
327
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
458
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
328
459
|
|
|
329
460
|
addHook(
|
|
330
461
|
name: 'onReady',
|
|
331
462
|
hook: onReadyAsyncHookHandler,
|
|
332
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
463
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
333
464
|
|
|
334
465
|
/**
|
|
335
466
|
* Triggered when fastify.close() is invoked to stop the server. It is useful when plugins need a "shutdown" event, for example to close an open connection to a database.
|
|
336
467
|
*/
|
|
337
468
|
addHook(
|
|
338
469
|
name: 'onClose',
|
|
339
|
-
hook: onCloseHookHandler<RawServer, RawRequest, RawReply, Logger>
|
|
340
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
470
|
+
hook: onCloseHookHandler<RawServer, RawRequest, RawReply, Logger, TypeProvider>
|
|
471
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
341
472
|
|
|
342
473
|
addHook(
|
|
343
474
|
name: 'onClose',
|
|
@@ -347,17 +478,17 @@ export interface FastifyInstance<
|
|
|
347
478
|
/**
|
|
348
479
|
* Set the 404 handler
|
|
349
480
|
*/
|
|
350
|
-
setNotFoundHandler<RouteGeneric extends RouteGenericInterface = RouteGenericInterface> (
|
|
351
|
-
handler: (request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric>) => void
|
|
352
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
481
|
+
setNotFoundHandler<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, SchemaCompiler extends FastifySchema = FastifySchema> (
|
|
482
|
+
handler: (request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfigDefault, SchemaCompiler, TypeProvider>) => void
|
|
483
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
353
484
|
|
|
354
|
-
setNotFoundHandler<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig extends ContextConfigDefault = ContextConfigDefault> (
|
|
485
|
+
setNotFoundHandler<RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig extends ContextConfigDefault = ContextConfigDefault, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault, SchemaCompiler extends FastifySchema = FastifySchema> (
|
|
355
486
|
opts: {
|
|
356
|
-
preValidation?: preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig> | preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>[];
|
|
357
|
-
preHandler?: preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig> | preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig>[];
|
|
487
|
+
preValidation?: preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider> | preValidationHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>[];
|
|
488
|
+
preHandler?: preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider> | preHandlerHookHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>[];
|
|
358
489
|
},
|
|
359
|
-
handler: (request: FastifyRequest<RouteGeneric, RawServer, RawRequest>, reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric>) => void
|
|
360
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>
|
|
490
|
+
handler: (request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfigDefault, SchemaCompiler, TypeProvider>) => void
|
|
491
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>
|
|
361
492
|
|
|
362
493
|
/**
|
|
363
494
|
* Fastify default error handler
|
|
@@ -367,24 +498,19 @@ export interface FastifyInstance<
|
|
|
367
498
|
/**
|
|
368
499
|
* Set a function that will be called whenever an error happens
|
|
369
500
|
*/
|
|
370
|
-
setErrorHandler<TError extends Error = FastifyError, RouteGeneric extends RouteGenericInterface = RouteGenericInterface>(
|
|
371
|
-
handler: (
|
|
372
|
-
|
|
373
|
-
error: TError,
|
|
374
|
-
request: FastifyRequest<RouteGeneric, RawServer, RawRequest>,
|
|
375
|
-
reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric>
|
|
376
|
-
) => void | Promise<RouteGeneric['Reply'] | void>
|
|
377
|
-
): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
501
|
+
setErrorHandler<TError extends Error = FastifyError, RouteGeneric extends RouteGenericInterface = RouteGenericInterface, SchemaCompiler extends FastifySchema = FastifySchema, TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault>(
|
|
502
|
+
handler: (this: FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>, error: TError, request: FastifyRequest<RouteGeneric, RawServer, RawRequest, SchemaCompiler, TypeProvider>, reply: FastifyReply<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfigDefault, SchemaCompiler, TypeProvider>) => any | Promise<any>
|
|
503
|
+
): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
378
504
|
|
|
379
505
|
/**
|
|
380
506
|
* Set the schema validator for all routes.
|
|
381
507
|
*/
|
|
382
|
-
setValidatorCompiler<T = FastifySchema>(schemaCompiler: FastifySchemaCompiler<T>): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
508
|
+
setValidatorCompiler<T = FastifySchema>(schemaCompiler: FastifySchemaCompiler<T>): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
383
509
|
|
|
384
510
|
/**
|
|
385
511
|
* Set the schema serializer for all routes.
|
|
386
512
|
*/
|
|
387
|
-
setSerializerCompiler<T = FastifySchema>(schemaCompiler: FastifySerializerCompiler<T>): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
513
|
+
setSerializerCompiler<T = FastifySchema>(schemaCompiler: FastifySerializerCompiler<T>): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
388
514
|
|
|
389
515
|
/**
|
|
390
516
|
* Set the schema controller for all routes.
|
|
@@ -394,16 +520,16 @@ export interface FastifyInstance<
|
|
|
394
520
|
/**
|
|
395
521
|
* Set the reply serializer for all routes.
|
|
396
522
|
*/
|
|
397
|
-
setReplySerializer(replySerializer: (payload: unknown, statusCode: number) => string): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
523
|
+
setReplySerializer(replySerializer: (payload: unknown, statusCode: number) => string): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
398
524
|
|
|
399
525
|
/*
|
|
400
526
|
* Set the schema error formatter for all routes.
|
|
401
527
|
*/
|
|
402
|
-
setSchemaErrorFormatter(errorFormatter: (errors: FastifySchemaValidationError[], dataVar: string) => Error): FastifyInstance<RawServer, RawRequest, RawReply, Logger>;
|
|
528
|
+
setSchemaErrorFormatter(errorFormatter: (errors: FastifySchemaValidationError[], dataVar: string) => Error): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
|
|
403
529
|
/**
|
|
404
530
|
* Add a content type parser
|
|
405
531
|
*/
|
|
406
|
-
addContentTypeParser: AddContentTypeParser<RawServer, RawRequest>;
|
|
532
|
+
addContentTypeParser: AddContentTypeParser<RawServer, RawRequest, RouteGenericInterface, FastifySchema, TypeProvider>;
|
|
407
533
|
hasContentTypeParser: hasContentTypeParser;
|
|
408
534
|
/**
|
|
409
535
|
* Remove an existing content type parser
|