fastify 5.0.0 → 5.2.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/.borp.yaml +3 -0
- package/.vscode/settings.json +22 -0
- package/README.md +12 -7
- package/docs/Guides/Database.md +15 -15
- package/docs/Guides/Detecting-When-Clients-Abort.md +28 -28
- package/docs/Guides/Ecosystem.md +14 -15
- package/docs/Guides/Index.md +1 -1
- package/docs/Guides/Migration-Guide-V4.md +11 -11
- package/docs/Guides/Migration-Guide-V5.md +133 -9
- package/docs/Guides/Plugins-Guide.md +1 -1
- package/docs/Guides/Prototype-Poisoning.md +3 -3
- package/docs/Guides/Recommendations.md +9 -9
- package/docs/Guides/Serverless.md +5 -5
- package/docs/Guides/Testing.md +58 -57
- package/docs/Guides/Write-Plugin.md +2 -2
- package/docs/Guides/Write-Type-Provider.md +3 -3
- package/docs/Reference/ContentTypeParser.md +4 -4
- package/docs/Reference/Decorators.md +2 -2
- package/docs/Reference/Errors.md +3 -3
- package/docs/Reference/Hooks.md +7 -7
- package/docs/Reference/LTS.md +8 -0
- package/docs/Reference/Logging.md +5 -4
- package/docs/Reference/Reply.md +55 -58
- package/docs/Reference/Request.md +49 -42
- package/docs/Reference/Routes.md +16 -13
- package/docs/Reference/Server.md +32 -28
- package/docs/Reference/TypeScript.md +9 -9
- package/docs/Reference/Validation-and-Serialization.md +5 -5
- package/examples/typescript-server.ts +1 -1
- package/fastify.d.ts +14 -5
- package/fastify.js +8 -6
- package/lib/contentTypeParser.js +9 -7
- package/lib/context.js +1 -2
- package/lib/error-handler.js +9 -9
- package/lib/errors.js +1 -1
- package/lib/fourOhFour.js +1 -1
- package/lib/hooks.js +4 -1
- package/lib/{logger.js → logger-factory.js} +70 -122
- package/lib/logger-pino.js +68 -0
- package/lib/pluginOverride.js +1 -1
- package/lib/pluginUtils.js +2 -2
- package/lib/reply.js +4 -5
- package/lib/request.js +16 -9
- package/lib/route.js +23 -22
- package/lib/validation.js +2 -2
- package/package.json +13 -15
- package/test/404s.test.js +675 -629
- package/test/500s.test.js +72 -63
- package/test/{allowUnsafeRegex.test.js → allow-unsafe-regex.test.js} +30 -26
- package/test/als.test.js +48 -45
- package/test/async-await.test.js +148 -134
- package/test/async-dispose.test.js +4 -5
- package/test/async_hooks.test.js +30 -28
- package/test/{bodyLimit.test.js → body-limit.test.js} +61 -58
- package/test/buffer.test.js +9 -10
- package/test/build/error-serializer.test.js +3 -4
- package/test/build/version.test.js +2 -3
- package/test/build-certificate.js +1 -1
- package/test/bundler/README.md +5 -5
- package/test/bundler/esbuild/bundler-test.js +10 -9
- package/test/bundler/webpack/bundler-test.js +10 -9
- package/test/case-insensitive.test.js +31 -28
- package/test/chainable.test.js +4 -5
- package/test/check.test.js +8 -10
- package/test/{childLoggerFactory.test.js → child-logger-factory.test.js} +56 -19
- package/test/client-timeout.test.js +5 -5
- package/test/close-pipelining.test.js +6 -8
- package/test/conditional-pino.test.js +47 -0
- package/test/{connectionTimeout.test.js → connection-timeout.test.js} +10 -11
- package/test/constrained-routes.test.js +243 -236
- package/test/content-length.test.js +53 -68
- package/test/content-parser.test.js +186 -158
- package/test/content-type.test.js +8 -9
- package/test/context-config.test.js +44 -54
- package/test/custom-http-server.test.js +16 -20
- package/test/custom-parser.5.test.js +32 -32
- package/test/diagnostics-channel/404.test.js +15 -15
- package/test/diagnostics-channel/async-delay-request.test.js +25 -25
- package/test/diagnostics-channel/async-request.test.js +24 -24
- package/test/diagnostics-channel/error-before-handler.test.js +4 -5
- package/test/diagnostics-channel/error-request.test.js +19 -19
- package/test/diagnostics-channel/error-status.test.js +8 -8
- package/test/diagnostics-channel/init.test.js +6 -7
- package/test/diagnostics-channel/sync-delay-request.test.js +16 -16
- package/test/diagnostics-channel/sync-request-reply.test.js +16 -16
- package/test/diagnostics-channel/sync-request.test.js +19 -19
- package/test/encapsulated-child-logger-factory.test.js +8 -8
- package/test/encapsulated-error-handler.test.js +20 -20
- package/test/esm/errorCodes.test.mjs +5 -5
- package/test/esm/esm.test.mjs +3 -3
- package/test/esm/named-exports.mjs +3 -3
- package/test/esm/other.mjs +2 -2
- package/test/fastify-instance.test.js +33 -34
- package/test/{findRoute.test.js → find-route.test.js} +11 -10
- package/test/fluent-schema.test.js +33 -36
- package/test/handler-context.test.js +11 -11
- package/test/has-route.test.js +12 -15
- package/test/header-overflow.test.js +13 -12
- package/test/hooks.on-ready.test.js +2 -2
- package/test/hooks.test.js +25 -25
- package/test/http-methods/copy.test.js +22 -24
- package/test/http-methods/custom-http-methods.test.js +24 -21
- package/test/http-methods/get.test.js +97 -84
- package/test/http-methods/head.test.js +63 -57
- package/test/http-methods/lock.test.js +21 -20
- package/test/http-methods/mkcalendar.test.js +31 -27
- package/test/http-methods/mkcol.test.js +10 -10
- package/test/http-methods/move.test.js +11 -11
- package/test/http-methods/propfind.test.js +32 -27
- package/test/http-methods/proppatch.test.js +21 -19
- package/test/http-methods/report.test.js +32 -27
- package/test/http-methods/search.test.js +52 -47
- package/test/http-methods/trace.test.js +3 -4
- package/test/http-methods/unlock.test.js +10 -10
- package/test/http2/closing.test.js +50 -58
- package/test/http2/constraint.test.js +47 -50
- package/test/http2/head.test.js +18 -19
- package/test/http2/missing-http2-module.test.js +4 -5
- package/test/http2/plain.test.js +31 -31
- package/test/http2/secure-with-fallback.test.js +61 -61
- package/test/http2/secure.test.js +28 -31
- package/test/http2/unknown-http-method.test.js +13 -14
- package/test/https/custom-https-server.test.js +6 -7
- package/test/https/https.test.js +78 -78
- package/test/imports.test.js +5 -6
- package/test/internals/all.test.js +8 -11
- package/test/internals/{contentTypeParser.test.js → content-type-parser.test.js} +5 -6
- package/test/internals/context.test.js +9 -11
- package/test/internals/decorator.test.js +20 -21
- package/test/internals/errors.test.js +427 -427
- package/test/internals/{handleRequest.test.js → handle-request.test.js} +53 -42
- package/test/internals/{hookRunner.test.js → hook-runner.test.js} +99 -100
- package/test/internals/hooks.test.js +31 -35
- package/test/internals/{initialConfig.test.js → initial-config.test.js} +92 -80
- package/test/internals/logger.test.js +28 -28
- package/test/internals/plugin.test.js +17 -18
- package/test/internals/reply-serialize.test.js +106 -106
- package/test/internals/reply.test.js +620 -585
- package/test/internals/{reqIdGenFactory.test.js → req-id-gen-factory.test.js} +31 -31
- package/test/internals/request-validate.test.js +218 -221
- package/test/internals/request.test.js +225 -107
- package/test/internals/server.test.js +15 -12
- package/test/internals/validation.test.js +35 -36
- package/test/{keepAliveTimeout.test.js → keep-alive-timeout.test.js} +9 -10
- package/test/listen.5.test.js +9 -9
- package/test/{maxRequestsPerSocket.test.js → max-requests-per-socket.test.js} +30 -30
- package/test/middleware.test.js +4 -5
- package/test/noop-set.test.js +5 -5
- package/test/post-empty-body.test.js +18 -11
- package/test/pretty-print.test.js +59 -49
- package/test/proto-poisoning.test.js +42 -37
- package/test/reply-code.test.js +34 -32
- package/test/{reply-earlyHints.test.js → reply-early-hints.test.js} +21 -19
- package/test/request-error.test.js +122 -0
- package/test/request-header-host.test.js +339 -0
- package/test/request-id.test.js +31 -25
- package/test/{requestTimeout.test.js → request-timeout.test.js} +11 -11
- package/test/route.1.test.js +79 -72
- package/test/route.2.test.js +17 -16
- package/test/route.3.test.js +32 -27
- package/test/route.4.test.js +21 -25
- package/test/route.5.test.js +45 -64
- package/test/route.6.test.js +70 -89
- package/test/route.7.test.js +61 -65
- package/test/route.8.test.js +80 -18
- package/test/router-options.test.js +80 -77
- package/test/same-shape.test.js +5 -5
- package/test/schema-examples.test.js +72 -38
- package/test/serialize-response.test.js +9 -10
- package/test/server.test.js +75 -78
- package/test/set-error-handler.test.js +2 -3
- package/test/stream-serializers.test.js +10 -7
- package/test/sync-routes.test.js +18 -18
- package/test/test-reporter.mjs +68 -0
- package/test/trust-proxy.test.js +51 -45
- package/test/type-provider.test.js +8 -6
- package/test/types/content-type-parser.test-d.ts +1 -1
- package/test/types/fastify.test-d.ts +16 -4
- package/test/types/hooks.test-d.ts +2 -1
- package/test/types/instance.test-d.ts +13 -13
- package/test/types/logger.test-d.ts +2 -2
- package/test/types/plugin.test-d.ts +17 -9
- package/test/types/register.test-d.ts +22 -6
- package/test/types/reply.test-d.ts +1 -1
- package/test/types/route.test-d.ts +34 -4
- package/test/types/serverFactory.test-d.ts +1 -1
- package/test/types/type-provider.test-d.ts +1 -1
- package/test/url-rewriting.test.js +35 -38
- package/test/{useSemicolonDelimiter.test.js → use-semicolon-delimiter.test.js} +30 -30
- package/test/validation-error-handling.test.js +259 -285
- package/test/versioned-routes.test.js +126 -113
- package/test/web-api.test.js +48 -37
- package/test/{wrapThenable.test.js → wrap-thenable.test.js} +10 -9
- package/types/hooks.d.ts +2 -1
- package/types/instance.d.ts +9 -2
- package/types/register.d.ts +12 -3
- package/types/reply.d.ts +1 -1
- package/types/request.d.ts +2 -6
- package/types/serverFactory.d.ts +3 -3
- package/types/utils.d.ts +13 -5
- package/test/types/import.js +0 -2
package/.borp.yaml
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"workbench.colorCustomizations": {
|
|
3
|
+
"[GitHub Dark]": {
|
|
4
|
+
"tab.activeBackground": "#0d0d0d",
|
|
5
|
+
"tab.activeBorder": "#ffff00"
|
|
6
|
+
},
|
|
7
|
+
"activityBar.background": "#FBE7B2",
|
|
8
|
+
"activityBar.foreground": "#52358C",
|
|
9
|
+
"activityBar.inactiveForeground": "#616161",
|
|
10
|
+
"activityBar.activeBorder": "#04184d",
|
|
11
|
+
"activityBar.activeBackground": "#C3B48B",
|
|
12
|
+
"activityBar.border": "#C3B48B",
|
|
13
|
+
"titleBar.activeBackground": "#D2BE88",
|
|
14
|
+
"titleBar.activeForeground": "#52358C",
|
|
15
|
+
"titleBar.inactiveBackground": "#bdb59c",
|
|
16
|
+
"titleBar.inactiveForeground": "#616161",
|
|
17
|
+
"titleBar.border": "#C3B48B",
|
|
18
|
+
"statusBar.background": "#E9DBB7",
|
|
19
|
+
"statusBar.foreground": "#52358C",
|
|
20
|
+
"statusBar.border": "#C3B48B"
|
|
21
|
+
}
|
|
22
|
+
}
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
<div align="center">
|
|
11
11
|
|
|
12
|
-
[](https://github.com/fastify/fastify/actions/workflows/ci.yml)
|
|
12
|
+
[](https://github.com/fastify/fastify/actions/workflows/ci.yml)
|
|
13
13
|
[](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml)
|
|
15
15
|
[](https://www.np
|
|
|
29
29
|
Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/fastify/blob/main/SECURITY.md)
|
|
30
30
|
[](https://discord.gg/fastify)
|
|
31
31
|
[](https://gitpod.io/#https://github.com/fastify/fastify)
|
|
32
|
-

|
|
32
|
+
[](https://github.com/sponsors/fastify#sponsors)
|
|
33
33
|
|
|
34
34
|
</div>
|
|
35
35
|
|
|
@@ -106,14 +106,9 @@ generate functionality of [Fastify CLI](https://github.com/fastify/fastify-cli).
|
|
|
106
106
|
|
|
107
107
|
To install Fastify in an existing project as a dependency:
|
|
108
108
|
|
|
109
|
-
Install with npm:
|
|
110
109
|
```sh
|
|
111
110
|
npm i fastify
|
|
112
111
|
```
|
|
113
|
-
Install with yarn:
|
|
114
|
-
```sh
|
|
115
|
-
yarn add fastify
|
|
116
|
-
```
|
|
117
112
|
|
|
118
113
|
### Example
|
|
119
114
|
|
|
@@ -266,6 +261,13 @@ application, you should __always__ benchmark if performance matters to you.
|
|
|
266
261
|
Please visit [Fastify help](https://github.com/fastify/help) to view prior
|
|
267
262
|
support issues and to ask new support questions.
|
|
268
263
|
|
|
264
|
+
Version 3 of Fastify and lower are EOL and will not receive any security or bug fixes.
|
|
265
|
+
|
|
266
|
+
Fastify's partner, HeroDevs, provides commercial security fixes for all
|
|
267
|
+
unsupported versions at [https://herodevs.com/support/fastify-nes][hd-link].
|
|
268
|
+
Fastify's supported version matrix is available in the
|
|
269
|
+
[Long Term Support][lts-link] documentation.
|
|
270
|
+
|
|
269
271
|
## Contributing
|
|
270
272
|
|
|
271
273
|
Whether reporting bugs, discussing improvements and new ideas or writing code,
|
|
@@ -414,3 +416,6 @@ dependencies:
|
|
|
414
416
|
- ISC
|
|
415
417
|
- BSD-3-Clause
|
|
416
418
|
- BSD-2-Clause
|
|
419
|
+
|
|
420
|
+
[hd-link]: https://www.herodevs.com/support/fastify-nes?utm_source=fastify&utm_medium=link&utm_campaign=github_readme
|
|
421
|
+
[lts-link]: https://fastify.dev/docs/latest/Reference/LTS/
|
package/docs/Guides/Database.md
CHANGED
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
## Database
|
|
4
4
|
|
|
5
|
-
Fastify's ecosystem provides a handful of
|
|
6
|
-
plugins for connecting to various database engines.
|
|
7
|
-
This guide covers engines that have Fastify
|
|
5
|
+
Fastify's ecosystem provides a handful of
|
|
6
|
+
plugins for connecting to various database engines.
|
|
7
|
+
This guide covers engines that have Fastify
|
|
8
8
|
plugins maintained within the Fastify organization.
|
|
9
9
|
|
|
10
|
-
> If a plugin for your database of choice does not exist
|
|
11
|
-
> you can still use the database as Fastify is database agnostic.
|
|
12
|
-
> By following the examples of the database plugins listed in this guide,
|
|
13
|
-
> a plugin can be written for the missing database engine.
|
|
10
|
+
> If a plugin for your database of choice does not exist
|
|
11
|
+
> you can still use the database as Fastify is database agnostic.
|
|
12
|
+
> By following the examples of the database plugins listed in this guide,
|
|
13
|
+
> a plugin can be written for the missing database engine.
|
|
14
14
|
|
|
15
|
-
> If you would like to write your own Fastify plugin
|
|
15
|
+
> If you would like to write your own Fastify plugin
|
|
16
16
|
> please take a look at the [plugins guide](./Plugins-Guide.md)
|
|
17
17
|
|
|
18
18
|
### [MySQL](https://github.com/fastify/fastify-mysql)
|
|
@@ -104,8 +104,8 @@ fastify.listen({ port: 3000 }, err => {
|
|
|
104
104
|
})
|
|
105
105
|
```
|
|
106
106
|
|
|
107
|
-
By default `@fastify/redis` doesn't close
|
|
108
|
-
the client connection when Fastify server shuts down.
|
|
107
|
+
By default `@fastify/redis` doesn't close
|
|
108
|
+
the client connection when Fastify server shuts down.
|
|
109
109
|
To opt-in to this behavior, register the client like so:
|
|
110
110
|
|
|
111
111
|
```javascript
|
|
@@ -126,7 +126,7 @@ fastify.register(require('@fastify/mongodb'), {
|
|
|
126
126
|
// force to close the mongodb connection when app stopped
|
|
127
127
|
// the default value is false
|
|
128
128
|
forceClose: true,
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
url: 'mongodb://mongo/mydb'
|
|
131
131
|
})
|
|
132
132
|
|
|
@@ -178,8 +178,8 @@ fastify.listen({ port: 3000 }, err => {
|
|
|
178
178
|
```
|
|
179
179
|
|
|
180
180
|
### Writing plugin for a database library
|
|
181
|
-
We could write a plugin for a database
|
|
182
|
-
library too (e.g. Knex, Prisma, or TypeORM).
|
|
181
|
+
We could write a plugin for a database
|
|
182
|
+
library too (e.g. Knex, Prisma, or TypeORM).
|
|
183
183
|
We will use [Knex](https://knexjs.org/) in our example.
|
|
184
184
|
|
|
185
185
|
```javascript
|
|
@@ -281,7 +281,7 @@ async function migrate() {
|
|
|
281
281
|
const client = new pg.Client({
|
|
282
282
|
host: 'localhost',
|
|
283
283
|
port: 5432,
|
|
284
|
-
database: 'example',
|
|
284
|
+
database: 'example',
|
|
285
285
|
user: 'example',
|
|
286
286
|
password: 'example',
|
|
287
287
|
});
|
|
@@ -313,7 +313,7 @@ async function migrate() {
|
|
|
313
313
|
console.error(err)
|
|
314
314
|
process.exitCode = 1
|
|
315
315
|
}
|
|
316
|
-
|
|
316
|
+
|
|
317
317
|
await client.end()
|
|
318
318
|
}
|
|
319
319
|
|
|
@@ -4,30 +4,30 @@
|
|
|
4
4
|
|
|
5
5
|
## Introduction
|
|
6
6
|
|
|
7
|
-
Fastify provides request events to trigger at certain points in a request's
|
|
8
|
-
lifecycle. However, there isn't a built-in mechanism to
|
|
9
|
-
detect unintentional client disconnection scenarios such as when the client's
|
|
7
|
+
Fastify provides request events to trigger at certain points in a request's
|
|
8
|
+
lifecycle. However, there isn't a built-in mechanism to
|
|
9
|
+
detect unintentional client disconnection scenarios such as when the client's
|
|
10
10
|
internet connection is interrupted. This guide covers methods to detect if
|
|
11
11
|
and when a client intentionally aborts a request.
|
|
12
12
|
|
|
13
|
-
Keep in mind, Fastify's `clientErrorHandler` is not designed to detect when a
|
|
14
|
-
client aborts a request. This works in the same way as the standard Node HTTP
|
|
15
|
-
module, which triggers the `clientError` event when there is a bad request or
|
|
16
|
-
exceedingly large header data. When a client aborts a request, there is no
|
|
13
|
+
Keep in mind, Fastify's `clientErrorHandler` is not designed to detect when a
|
|
14
|
+
client aborts a request. This works in the same way as the standard Node HTTP
|
|
15
|
+
module, which triggers the `clientError` event when there is a bad request or
|
|
16
|
+
exceedingly large header data. When a client aborts a request, there is no
|
|
17
17
|
error on the socket and the `clientErrorHandler` will not be triggered.
|
|
18
18
|
|
|
19
19
|
## Solution
|
|
20
20
|
|
|
21
21
|
### Overview
|
|
22
22
|
|
|
23
|
-
The proposed solution is a possible way of detecting when a client
|
|
24
|
-
intentionally aborts a request, such as when a browser is closed or the HTTP
|
|
25
|
-
request is aborted from your client application. If there is an error in your
|
|
26
|
-
application code that results in the server crashing, you may require
|
|
23
|
+
The proposed solution is a possible way of detecting when a client
|
|
24
|
+
intentionally aborts a request, such as when a browser is closed or the HTTP
|
|
25
|
+
request is aborted from your client application. If there is an error in your
|
|
26
|
+
application code that results in the server crashing, you may require
|
|
27
27
|
additional logic to avoid a false abort detection.
|
|
28
28
|
|
|
29
|
-
The goal here is to detect when a client intentionally aborts a connection
|
|
30
|
-
so your application logic can proceed accordingly. This can be useful for
|
|
29
|
+
The goal here is to detect when a client intentionally aborts a connection
|
|
30
|
+
so your application logic can proceed accordingly. This can be useful for
|
|
31
31
|
logging purposes or halting business logic.
|
|
32
32
|
|
|
33
33
|
### Hands-on
|
|
@@ -78,10 +78,10 @@ const start = async () => {
|
|
|
78
78
|
start()
|
|
79
79
|
```
|
|
80
80
|
|
|
81
|
-
Our code is setting up a Fastify server which includes the following
|
|
81
|
+
Our code is setting up a Fastify server which includes the following
|
|
82
82
|
functionality:
|
|
83
83
|
|
|
84
|
-
- Accepting requests at http://localhost:3000, with a 3 second delayed response
|
|
84
|
+
- Accepting requests at http://localhost:3000, with a 3 second delayed response
|
|
85
85
|
of `{ ok: true }`.
|
|
86
86
|
- An onRequest hook that triggers when every request is received.
|
|
87
87
|
- Logic that triggers in the hook when the request is closed.
|
|
@@ -108,7 +108,7 @@ app.get('/', async (request, reply) => {
|
|
|
108
108
|
})
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
At any point in your business logic, you can check if the request has been
|
|
111
|
+
At any point in your business logic, you can check if the request has been
|
|
112
112
|
aborted and perform alternative actions.
|
|
113
113
|
|
|
114
114
|
```js
|
|
@@ -122,14 +122,14 @@ app.get('/', async (request, reply) => {
|
|
|
122
122
|
})
|
|
123
123
|
```
|
|
124
124
|
|
|
125
|
-
A benefit to adding this in your application code is that you can log Fastify
|
|
126
|
-
details such as the reqId, which may be unavailable in lower-level code that
|
|
125
|
+
A benefit to adding this in your application code is that you can log Fastify
|
|
126
|
+
details such as the reqId, which may be unavailable in lower-level code that
|
|
127
127
|
only has access to the raw request information.
|
|
128
128
|
|
|
129
129
|
### Testing
|
|
130
130
|
|
|
131
|
-
To test this functionality you can use an app like Postman and cancel your
|
|
132
|
-
request within 3 seconds. Alternatively, you can use Node to send an HTTP
|
|
131
|
+
To test this functionality you can use an app like Postman and cancel your
|
|
132
|
+
request within 3 seconds. Alternatively, you can use Node to send an HTTP
|
|
133
133
|
request with logic to abort the request before 3 seconds. Example:
|
|
134
134
|
|
|
135
135
|
```js
|
|
@@ -151,7 +151,7 @@ setTimeout(() => {
|
|
|
151
151
|
}, 1000);
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
-
With either approach, you should see the Fastify log appear at the moment the
|
|
154
|
+
With either approach, you should see the Fastify log appear at the moment the
|
|
155
155
|
request is aborted.
|
|
156
156
|
|
|
157
157
|
## Conclusion
|
|
@@ -160,13 +160,13 @@ Specifics of the implementation will vary from one problem to another, but the
|
|
|
160
160
|
main goal of this guide was to show a very specific use case of an issue that
|
|
161
161
|
could be solved within Fastify's ecosystem.
|
|
162
162
|
|
|
163
|
-
You can listen to the request close event and determine if the request was
|
|
164
|
-
aborted or if it was successfully delivered. You can implement this solution
|
|
163
|
+
You can listen to the request close event and determine if the request was
|
|
164
|
+
aborted or if it was successfully delivered. You can implement this solution
|
|
165
165
|
in an onRequest hook or directly in an individual route.
|
|
166
166
|
|
|
167
|
-
This approach will not trigger in the event of internet disruption, and such
|
|
168
|
-
detection would require additional business logic. If you have flawed backend
|
|
169
|
-
application logic that results in a server crash, then you could trigger a
|
|
170
|
-
false detection. The `clientErrorHandler`, either by default or with custom
|
|
171
|
-
logic, is not intended to handle this scenario and will not trigger when the
|
|
167
|
+
This approach will not trigger in the event of internet disruption, and such
|
|
168
|
+
detection would require additional business logic. If you have flawed backend
|
|
169
|
+
application logic that results in a server crash, then you could trigger a
|
|
170
|
+
false detection. The `clientErrorHandler`, either by default or with custom
|
|
171
|
+
logic, is not intended to handle this scenario and will not trigger when the
|
|
172
172
|
client aborts a request.
|
package/docs/Guides/Ecosystem.md
CHANGED
|
@@ -12,8 +12,6 @@ section.
|
|
|
12
12
|
[accepts](https://www.npmjs.com/package/accepts) in your request object.
|
|
13
13
|
- [`@fastify/accepts-serializer`](https://github.com/fastify/fastify-accepts-serializer)
|
|
14
14
|
to serialize to output according to the `Accept` header.
|
|
15
|
-
- [`@fastify/any-schema`](https://github.com/fastify/any-schema-you-like) Save
|
|
16
|
-
multiple schemas and decide which one to use to serialize the payload.
|
|
17
15
|
- [`@fastify/auth`](https://github.com/fastify/fastify-auth) Run multiple auth
|
|
18
16
|
functions in Fastify.
|
|
19
17
|
- [`@fastify/autoload`](https://github.com/fastify/fastify-autoload) Require all
|
|
@@ -43,10 +41,7 @@ section.
|
|
|
43
41
|
[CSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) protection to
|
|
44
42
|
Fastify.
|
|
45
43
|
- [`@fastify/diagnostics-channel`](https://github.com/fastify/fastify-diagnostics-channel)
|
|
46
|
-
Plugin to deal with `diagnostics_channel` on Fastify
|
|
47
|
-
- [`@fastify/early-hints`](https://github.com/fastify/fastify-early-hints) Plugin
|
|
48
|
-
to add HTTP 103 feature based on [RFC
|
|
49
|
-
8297](https://datatracker.ietf.org/doc/html/rfc8297).
|
|
44
|
+
Plugin to deal with `diagnostics_channel` on Fastify.
|
|
50
45
|
- [`@fastify/elasticsearch`](https://github.com/fastify/fastify-elasticsearch)
|
|
51
46
|
Plugin to share the same ES client.
|
|
52
47
|
- [`@fastify/env`](https://github.com/fastify/fastify-env) Load and check
|
|
@@ -124,8 +119,6 @@ section.
|
|
|
124
119
|
HTTP errors and assertions, but also more request and reply methods.
|
|
125
120
|
- [`@fastify/session`](https://github.com/fastify/session) a session plugin for
|
|
126
121
|
Fastify.
|
|
127
|
-
- [`@fastify/soap-client`](https://github.com/fastify/fastify-soap-client) a SOAP
|
|
128
|
-
client plugin for Fastify.
|
|
129
122
|
- [`@fastify/static`](https://github.com/fastify/fastify-static) Plugin for
|
|
130
123
|
serving static files as fast as possible.
|
|
131
124
|
- [`@fastify/swagger`](https://github.com/fastify/fastify-swagger) Plugin for
|
|
@@ -182,6 +175,10 @@ section.
|
|
|
182
175
|
- [`@ethicdevs/fastify-git-server`](https://github.com/EthicDevs/fastify-git-server)
|
|
183
176
|
A plugin to easily create git server and make one/many Git repositories available
|
|
184
177
|
for clone/fetch/push through the standard `git` (over http) commands.
|
|
178
|
+
- [`@exortek/fastify-mongo-sanitize`](https://github.com/ExorTek/fastify-mongo-sanitize)
|
|
179
|
+
A Fastify plugin that protects against No(n)SQL injection by sanitizing data.
|
|
180
|
+
- [`@exortek/remix-fastify`](https://github.com/ExorTek/remix-fastify)
|
|
181
|
+
Fastify plugin for Remix.
|
|
185
182
|
- [`@fastify-userland/request-id`](https://github.com/fastify-userland/request-id)
|
|
186
183
|
Fastify Request ID Plugin
|
|
187
184
|
- [`@fastify-userland/typeorm-query-runner`](https://github.com/fastify-userland/typeorm-query-runner)
|
|
@@ -221,9 +218,9 @@ section.
|
|
|
221
218
|
Beautiful OpenAPI/Swagger API references for Fastify
|
|
222
219
|
- [`@trubavuong/fastify-seaweedfs`](https://github.com/trubavuong/fastify-seaweedfs)
|
|
223
220
|
SeaweedFS for Fastify
|
|
224
|
-
- [`apitally`](https://github.com/apitally/
|
|
225
|
-
integrate with [Apitally](https://apitally.io),
|
|
226
|
-
|
|
221
|
+
- [`apitally`](https://github.com/apitally/apitally-js) Fastify plugin to
|
|
222
|
+
integrate with [Apitally](https://apitally.io/fastify), an API analytics,
|
|
223
|
+
logging and monitoring tool.
|
|
227
224
|
- [`arecibo`](https://github.com/nucleode/arecibo) Fastify ping responder for
|
|
228
225
|
Kubernetes Liveness and Readiness Probes.
|
|
229
226
|
- [`aws-xray-sdk-fastify`](https://github.com/aws/aws-xray-sdk-node/tree/master/sdk_contrib/fastify)
|
|
@@ -256,7 +253,7 @@ section.
|
|
|
256
253
|
plugin to authenticate HTTP requests based on API key and signature
|
|
257
254
|
- [`fastify-appwrite`](https://github.com/Dev-Manny/fastify-appwrite) Fastify
|
|
258
255
|
Plugin for interacting with Appwrite server.
|
|
259
|
-
- [`fastify-asyncforge`](https://github.com/mcollina/fastify-asyncforge) Plugin
|
|
256
|
+
- [`fastify-asyncforge`](https://github.com/mcollina/fastify-asyncforge) Plugin
|
|
260
257
|
to access Fastify instance, logger, request and reply from Node.js [Async
|
|
261
258
|
Local Storage](https://nodejs.org/api/async_context.html#class-asynclocalstorage).
|
|
262
259
|
- [`fastify-at-mysql`](https://github.com/mateonunez/fastify-at-mysql) Fastify
|
|
@@ -284,7 +281,7 @@ section.
|
|
|
284
281
|
development servers that require Babel transformations of JavaScript sources.
|
|
285
282
|
- [`fastify-bcrypt`](https://github.com/beliven-it/fastify-bcrypt) A Bcrypt hash
|
|
286
283
|
generator & checker.
|
|
287
|
-
- [`fastify-better-sqlite3`](https://github.com/punkish/fastify-better-sqlite3)
|
|
284
|
+
- [`fastify-better-sqlite3`](https://github.com/punkish/fastify-better-sqlite3)
|
|
288
285
|
Plugin for better-sqlite3.
|
|
289
286
|
- [`fastify-blipp`](https://github.com/PavelPolyakov/fastify-blipp) Prints your
|
|
290
287
|
routes to the console, so you definitely know which endpoints are available.
|
|
@@ -296,7 +293,7 @@ section.
|
|
|
296
293
|
to add [bree](https://github.com/breejs/bree) support.
|
|
297
294
|
- [`fastify-bugsnag`](https://github.com/ZigaStrgar/fastify-bugsnag) Fastify plugin
|
|
298
295
|
to add support for [Bugsnag](https://www.bugsnag.com/) error reporting.
|
|
299
|
-
- [`fastify-cacheman`](https://gitlab.com/aalfiann/fastify-cacheman)
|
|
296
|
+
- [`fastify-cacheman`](https://gitlab.com/aalfiann/fastify-cacheman)
|
|
300
297
|
Small and efficient cache provider for Node.js with In-memory, File, Redis
|
|
301
298
|
and MongoDB engines for Fastify
|
|
302
299
|
- [`fastify-casbin`](https://github.com/nearform/fastify-casbin) Casbin support
|
|
@@ -351,7 +348,7 @@ section.
|
|
|
351
348
|
- [`fastify-event-bus`](https://github.com/Shiva127/fastify-event-bus) Event bus
|
|
352
349
|
support for Fastify. Built upon [js-event-bus](https://github.com/bcerati/js-event-bus).
|
|
353
350
|
- [`fastify-evervault`](https://github.com/Briscoooe/fastify-evervault/) Fastify
|
|
354
|
-
plugin for instantiating and encapsulating the
|
|
351
|
+
plugin for instantiating and encapsulating the
|
|
355
352
|
[Evervault](https://evervault.com/) client.
|
|
356
353
|
- [`fastify-explorer`](https://github.com/Eomm/fastify-explorer) Get control of
|
|
357
354
|
your decorators across all the encapsulated contexts.
|
|
@@ -545,6 +542,8 @@ middlewares into Fastify plugins
|
|
|
545
542
|
OSM plugin to run overpass queries by OpenStreetMap.
|
|
546
543
|
- [`fastify-override`](https://github.com/matthyk/fastify-override)
|
|
547
544
|
Fastify plugin to override decorators, plugins and hooks for testing purposes
|
|
545
|
+
- [`fastify-passkit-webservice`](https://github.com/alexandercerutti/fastify-passkit-webservice)
|
|
546
|
+
A set of Fastify plugins to integrate Apple Wallet Web Service specification
|
|
548
547
|
- [`fastify-peekaboo`](https://github.com/simone-sanfratello/fastify-peekaboo)
|
|
549
548
|
Fastify plugin for memoize responses by expressive settings.
|
|
550
549
|
- [`fastify-piscina`](https://github.com/piscinajs/fastify-piscina) A worker
|
package/docs/Guides/Index.md
CHANGED
|
@@ -15,7 +15,7 @@ This table of contents is in alphabetical order.
|
|
|
15
15
|
met in your application. This guide focuses on solving the problem using
|
|
16
16
|
[`Hooks`](../Reference/Hooks.md), [`Decorators`](../Reference/Decorators.md),
|
|
17
17
|
and [`Plugins`](../Reference/Plugins.md).
|
|
18
|
-
+ [Detecting When Clients Abort](./Detecting-When-Clients-Abort.md): A
|
|
18
|
+
+ [Detecting When Clients Abort](./Detecting-When-Clients-Abort.md): A
|
|
19
19
|
practical guide on detecting if and when a client aborts a request.
|
|
20
20
|
+ [Ecosystem](./Ecosystem.md): Lists all core plugins and many known community
|
|
21
21
|
plugins.
|
|
@@ -9,13 +9,13 @@ work after upgrading.
|
|
|
9
9
|
## Codemods
|
|
10
10
|
### Fastify v4 Codemods
|
|
11
11
|
|
|
12
|
-
To help with the upgrade, we’ve worked with the team at
|
|
12
|
+
To help with the upgrade, we’ve worked with the team at
|
|
13
13
|
[Codemod](https://github.com/codemod-com/codemod) to
|
|
14
|
-
publish codemods that will automatically update your code to many of
|
|
14
|
+
publish codemods that will automatically update your code to many of
|
|
15
15
|
the new APIs and patterns in Fastify v4.
|
|
16
16
|
|
|
17
|
-
Run the following
|
|
18
|
-
[migration recipe](https://go.codemod.com/fastify-4-migration-recipe) to
|
|
17
|
+
Run the following
|
|
18
|
+
[migration recipe](https://go.codemod.com/fastify-4-migration-recipe) to
|
|
19
19
|
automatically update your code to Fastify v4:
|
|
20
20
|
|
|
21
21
|
```
|
|
@@ -30,7 +30,7 @@ This will run the following codemods:
|
|
|
30
30
|
- [`fastify/4/await-register-calls`](https://go.codemod.com/fastify-4-await-register-calls)
|
|
31
31
|
|
|
32
32
|
Each of these codemods automates the changes listed in the v4 migration guide.
|
|
33
|
-
For a complete list of available Fastify codemods and further details,
|
|
33
|
+
For a complete list of available Fastify codemods and further details,
|
|
34
34
|
see [Codemod Registry](https://go.codemod.com/fastify).
|
|
35
35
|
|
|
36
36
|
|
|
@@ -52,14 +52,14 @@ fastify.register(async fastify => {
|
|
|
52
52
|
console.log(err.message) // 'kaboom'
|
|
53
53
|
throw new Error('caught')
|
|
54
54
|
})
|
|
55
|
-
|
|
55
|
+
|
|
56
56
|
fastify.get('/encapsulated', async () => {
|
|
57
57
|
throw new Error('kaboom')
|
|
58
58
|
})
|
|
59
59
|
})
|
|
60
60
|
|
|
61
61
|
fastify.setErrorHandler(async err => {
|
|
62
|
-
console.log(err.message) // 'caught'
|
|
62
|
+
console.log(err.message) // 'caught'
|
|
63
63
|
throw new Error('wrapped')
|
|
64
64
|
})
|
|
65
65
|
|
|
@@ -67,10 +67,10 @@ const res = await fastify.inject('/encapsulated')
|
|
|
67
67
|
console.log(res.json().message) // 'wrapped'
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
>The root error handler is Fastify’s generic error handler.
|
|
71
|
-
>This error handler will use the headers and status code in the Error object,
|
|
70
|
+
>The root error handler is Fastify’s generic error handler.
|
|
71
|
+
>This error handler will use the headers and status code in the Error object,
|
|
72
72
|
>if they exist. **The headers and status code will not be automatically set if
|
|
73
|
-
>a custom error handler is provided**.
|
|
73
|
+
>a custom error handler is provided**.
|
|
74
74
|
|
|
75
75
|
### Removed `app.use()` ([#3506](https://github.com/fastify/fastify/pull/3506))
|
|
76
76
|
|
|
@@ -242,7 +242,7 @@ As such, schemas like below will need to be changed from:
|
|
|
242
242
|
properties: {
|
|
243
243
|
api_key: { type: 'string' },
|
|
244
244
|
image: { type: ['object', 'array'] }
|
|
245
|
-
}
|
|
245
|
+
}
|
|
246
246
|
}
|
|
247
247
|
```
|
|
248
248
|
|
|
@@ -159,7 +159,7 @@ the following:
|
|
|
159
159
|
+++ b/index.ts
|
|
160
160
|
@@ -11,7 +11,8 @@ import {
|
|
161
161
|
import { FromSchema, FromSchemaDefaultOptions, FromSchemaOptions, JSONSchema } from 'json-schema-to-ts'
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
export interface JsonSchemaToTsProvider<
|
|
164
164
|
Options extends FromSchemaOptions = FromSchemaDefaultOptions
|
|
165
165
|
> extends FastifyTypeProvider {
|
|
@@ -298,7 +298,7 @@ use the `constraints` option instead.
|
|
|
298
298
|
We have a more strict requirement for custom `HEAD` route when
|
|
299
299
|
`exposeHeadRoutes: true`.
|
|
300
300
|
|
|
301
|
-
When you provides a custom `HEAD` route, you must either explicitly
|
|
301
|
+
When you provides a custom `HEAD` route, you must either explicitly
|
|
302
302
|
set `exposeHeadRoutes` to `false`
|
|
303
303
|
|
|
304
304
|
```js
|
|
@@ -403,7 +403,7 @@ and requires the route definition to be passed as it is defined in the route.
|
|
|
403
403
|
fastify.get('/example/:file(^\\d+).png', function (request, reply) { })
|
|
404
404
|
|
|
405
405
|
console.log(fastify.hasRoute({
|
|
406
|
-
method: 'GET',
|
|
406
|
+
method: 'GET',
|
|
407
407
|
url: '/example/12345.png'
|
|
408
408
|
)); // true
|
|
409
409
|
```
|
|
@@ -414,7 +414,7 @@ console.log(fastify.hasRoute({
|
|
|
414
414
|
fastify.get('/example/:file(^\\d+).png', function (request, reply) { })
|
|
415
415
|
|
|
416
416
|
console.log(fastify.hasRoute({
|
|
417
|
-
method: 'GET',
|
|
417
|
+
method: 'GET',
|
|
418
418
|
url: '/example/:file(^\\d+).png'
|
|
419
419
|
)); // true
|
|
420
420
|
```
|
|
@@ -432,16 +432,16 @@ We have removed the following HTTP methods from Fastify:
|
|
|
432
432
|
- `TRACE`
|
|
433
433
|
- `SEARCH`
|
|
434
434
|
|
|
435
|
-
It's now possible to add them back using the `
|
|
435
|
+
It's now possible to add them back using the `addHttpMethod` method.
|
|
436
436
|
|
|
437
437
|
```js
|
|
438
438
|
const fastify = Fastify()
|
|
439
439
|
|
|
440
440
|
// add a new http method on top of the default ones:
|
|
441
|
-
fastify.
|
|
441
|
+
fastify.addHttpMethod('REBIND')
|
|
442
442
|
|
|
443
443
|
// add a new HTTP method that accepts a body:
|
|
444
|
-
fastify.
|
|
444
|
+
fastify.addHttpMethod('REBIND', { hasBody: true })
|
|
445
445
|
|
|
446
446
|
// reads the HTTP methods list:
|
|
447
447
|
fastify.supportedMethods // returns a string array
|
|
@@ -480,7 +480,7 @@ or as a getter
|
|
|
480
480
|
```js
|
|
481
481
|
// v5
|
|
482
482
|
fastify.decorateRequest('myObject', {
|
|
483
|
-
getter () {
|
|
483
|
+
getter () {
|
|
484
484
|
return { hello: 'world' }
|
|
485
485
|
}
|
|
486
486
|
});
|
|
@@ -538,7 +538,7 @@ so you should have already updated your code.
|
|
|
538
538
|
|
|
539
539
|
### Diagnostic Channel support
|
|
540
540
|
|
|
541
|
-
Fastify v5 now supports the [
|
|
541
|
+
Fastify v5 now supports the [Diagnostics Channel](https://nodejs.org/api/diagnostics_channel.html)
|
|
542
542
|
API natively
|
|
543
543
|
and provides a way to trace the lifecycle of a request.
|
|
544
544
|
|
|
@@ -586,3 +586,127 @@ fastify.listen({ port: 0 }, function () {
|
|
|
586
586
|
|
|
587
587
|
See the [documentation](https://github.com/fastify/fastify/blob/main/docs/Reference/Hooks.md#diagnostics-channel-hooks)
|
|
588
588
|
and [#5252](https://github.com/fastify/fastify/pull/5252) for additional details.
|
|
589
|
+
|
|
590
|
+
## Contributors
|
|
591
|
+
|
|
592
|
+
The complete list of contributors, across all of the core
|
|
593
|
+
Fastify packages, is provided below. Please consider
|
|
594
|
+
contributing to those that are capable of accepting sponsorships.
|
|
595
|
+
|
|
596
|
+
| Contributor | Sponsor Link | Packages |
|
|
597
|
+
| --- | --- | --- |
|
|
598
|
+
| 10xLaCroixDrinker | [❤️ sponsor](https://github.com/sponsors/10xLaCroixDrinker) | fastify-cli |
|
|
599
|
+
| Bram-dc | | fastify; fastify-swagger |
|
|
600
|
+
| BrianValente | | fastify |
|
|
601
|
+
| BryanAbate | | fastify-cli |
|
|
602
|
+
| Cadienvan | [❤️ sponsor](https://github.com/sponsors/Cadienvan) | fastify |
|
|
603
|
+
| Cangit | | fastify |
|
|
604
|
+
| Cyberlane | | fastify-elasticsearch |
|
|
605
|
+
| Eomm | [❤️ sponsor](https://github.com/sponsors/Eomm) | ajv-compiler; fastify; fastify-awilix; fastify-diagnostics-channel; fastify-elasticsearch; fastify-hotwire; fastify-mongodb; fastify-nextjs; fastify-swagger-ui; under-pressure |
|
|
606
|
+
| EstebanDalelR | [❤️ sponsor](https://github.com/sponsors/EstebanDalelR) | fastify-cli |
|
|
607
|
+
| Fdawgs | [❤️ sponsor](https://github.com/sponsors/Fdawgs) | aws-lambda-fastify; csrf-protection; env-schema; fastify; fastify-accepts; fastify-accepts-serializer; fastify-auth; fastify-awilix; fastify-basic-auth; fastify-bearer-auth; fastify-caching; fastify-circuit-breaker; fastify-cli; fastify-cookie; fastify-cors; fastify-diagnostics-channel; fastify-elasticsearch; fastify-env; fastify-error; fastify-etag; fastify-express; fastify-flash; fastify-formbody; fastify-funky; fastify-helmet; fastify-hotwire; fastify-http-proxy; fastify-jwt; fastify-kafka; fastify-leveldb; fastify-mongodb; fastify-multipart; fastify-mysql; fastify-nextjs; fastify-oauth2; fastify-passport; fastify-plugin; fastify-postgres; fastify-rate-limit; fastify-redis; fastify-reply-from; fastify-request-context; fastify-response-validation; fastify-routes; fastify-routes-stats; fastify-schedule; fastify-secure-session; fastify-sensible; fastify-swagger-ui; fastify-url-data; fastify-websocket; fastify-zipkin; fluent-json-schema; forwarded; middie; point-of-view; process-warning; proxy-addr; safe-regex2; secure-json-parse; under-pressure |
|
|
608
|
+
| Gehbt | | fastify-secure-session |
|
|
609
|
+
| Gesma94 | | fastify-routes-stats |
|
|
610
|
+
| H4ad | [❤️ sponsor](https://github.com/sponsors/H4ad) | aws-lambda-fastify |
|
|
611
|
+
| JohanManders | | fastify-secure-session |
|
|
612
|
+
| LiviaMedeiros | | fastify |
|
|
613
|
+
| Momy93 | | fastify-secure-session |
|
|
614
|
+
| MunifTanjim | | fastify-swagger-ui |
|
|
615
|
+
| Nanosync | | fastify-secure-session |
|
|
616
|
+
| RafaelGSS | [❤️ sponsor](https://github.com/sponsors/RafaelGSS) | fastify; under-pressure |
|
|
617
|
+
| Rantoledo | | fastify |
|
|
618
|
+
| SMNBLMRR | | fastify |
|
|
619
|
+
| SimoneDevkt | | fastify-cli |
|
|
620
|
+
| Tony133 | | fastify |
|
|
621
|
+
| Uzlopak | [❤️ sponsor](https://github.com/sponsors/Uzlopak) | fastify; fastify-autoload; fastify-diagnostics-channel; fastify-hotwire; fastify-nextjs; fastify-passport; fastify-plugin; fastify-rate-limit; fastify-routes; fastify-static; fastify-swagger-ui; point-of-view; under-pressure |
|
|
622
|
+
| Zamiell | | fastify-secure-session |
|
|
623
|
+
| aadito123 | | fastify |
|
|
624
|
+
| aaroncadillac | [❤️ sponsor](https://github.com/sponsors/aaroncadillac) | fastify |
|
|
625
|
+
| aarontravass | | fastify |
|
|
626
|
+
| acro5piano | [❤️ sponsor](https://github.com/sponsors/acro5piano) | fastify-secure-session |
|
|
627
|
+
| adamward459 | | fastify-cli |
|
|
628
|
+
| adrai | [❤️ sponsor](https://github.com/sponsors/adrai) | aws-lambda-fastify |
|
|
629
|
+
| alenap93 | | fastify |
|
|
630
|
+
| alexandrucancescu | | fastify-nextjs |
|
|
631
|
+
| anthonyringoet | | aws-lambda-fastify |
|
|
632
|
+
| arshcodemod | | fastify |
|
|
633
|
+
| autopulated | | point-of-view |
|
|
634
|
+
| barbieri | | fastify |
|
|
635
|
+
| beyazit | | fastify |
|
|
636
|
+
| big-kahuna-burger | [❤️ sponsor](https://github.com/sponsors/big-kahuna-burger) | fastify-cli; fastify-compress; fastify-helmet |
|
|
637
|
+
| bilalshareef | | fastify-routes |
|
|
638
|
+
| blue86321 | | fastify-swagger-ui |
|
|
639
|
+
| bodinsamuel | | fastify-rate-limit |
|
|
640
|
+
| busybox11 | [❤️ sponsor](https://github.com/sponsors/busybox11) | fastify |
|
|
641
|
+
| climba03003 | | csrf-protection; fastify; fastify-accepts; fastify-accepts-serializer; fastify-auth; fastify-basic-auth; fastify-bearer-auth; fastify-caching; fastify-circuit-breaker; fastify-compress; fastify-cors; fastify-env; fastify-etag; fastify-flash; fastify-formbody; fastify-http-proxy; fastify-mongodb; fastify-swagger-ui; fastify-url-data; fastify-websocket; middie |
|
|
642
|
+
| dancastillo | [❤️ sponsor](https://github.com/sponsors/dancastillo) | fastify; fastify-basic-auth; fastify-caching; fastify-circuit-breaker; fastify-cors; fastify-helmet; fastify-passport; fastify-response-validation; fastify-routes; fastify-schedule |
|
|
643
|
+
| danny-andrews | | fastify-kafka |
|
|
644
|
+
| davidcralph | [❤️ sponsor](https://github.com/sponsors/davidcralph) | csrf-protection |
|
|
645
|
+
| davideroffo | | under-pressure |
|
|
646
|
+
| dhensby | | fastify-cli |
|
|
647
|
+
| dmkng | | fastify |
|
|
648
|
+
| domdomegg | | fastify |
|
|
649
|
+
| faustman | | fastify-cli |
|
|
650
|
+
| floridemai | | fluent-json-schema |
|
|
651
|
+
| fox1t | | fastify-autoload |
|
|
652
|
+
| giuliowaitforitdavide | | fastify |
|
|
653
|
+
| gunters63 | | fastify-reply-from |
|
|
654
|
+
| gurgunday | | fastify; fastify-circuit-breaker; fastify-cookie; fastify-multipart; fastify-mysql; fastify-rate-limit; fastify-response-validation; fastify-sensible; fastify-swagger-ui; fluent-json-schema; middie; proxy-addr; safe-regex2; secure-json-parse |
|
|
655
|
+
| ildella | | under-pressure |
|
|
656
|
+
| james-kaguru | | fastify |
|
|
657
|
+
| jcbain | | fastify-http-proxy |
|
|
658
|
+
| jdhollander | | fastify-swagger-ui |
|
|
659
|
+
| jean-michelet | | fastify; fastify-autoload; fastify-cli; fastify-mysql; fastify-sensible |
|
|
660
|
+
| johaven | | fastify-multipart |
|
|
661
|
+
| jordanebelanger | | fastify-plugin |
|
|
662
|
+
| jscheffner | | fastify |
|
|
663
|
+
| jsprw | | fastify-secure-session |
|
|
664
|
+
| jsumners | [❤️ sponsor](https://github.com/sponsors/jsumners) | ajv-compiler; avvio; csrf-protection; env-schema; fast-json-stringify; fastify; fastify-accepts; fastify-accepts-serializer; fastify-auth; fastify-autoload; fastify-awilix; fastify-basic-auth; fastify-bearer-auth; fastify-caching; fastify-circuit-breaker; fastify-compress; fastify-cookie; fastify-cors; fastify-env; fastify-error; fastify-etag; fastify-express; fastify-flash; fastify-formbody; fastify-funky; fastify-helmet; fastify-http-proxy; fastify-jwt; fastify-kafka; fastify-leveldb; fastify-multipart; fastify-mysql; fastify-oauth2; fastify-plugin; fastify-postgres; fastify-redis; fastify-reply-from; fastify-request-context; fastify-response-validation; fastify-routes; fastify-routes-stats; fastify-schedule; fastify-secure-session; fastify-sensible; fastify-static; fastify-swagger; fastify-swagger-ui; fastify-url-data; fastify-websocket; fastify-zipkin; fluent-json-schema; forwarded; light-my-request; middie; process-warning; proxy-addr; safe-regex2; secure-json-parse; under-pressure |
|
|
665
|
+
| karankraina | | under-pressure |
|
|
666
|
+
| kerolloz | [❤️ sponsor](https://github.com/sponsors/kerolloz) | fastify-jwt |
|
|
667
|
+
| kibertoad | | fastify-rate-limit |
|
|
668
|
+
| kukidon-dev | | fastify-passport |
|
|
669
|
+
| kunal097 | | fastify |
|
|
670
|
+
| lamweili | | fastify-sensible |
|
|
671
|
+
| lemonclown | | fastify-mongodb |
|
|
672
|
+
| liuhanqu | | fastify |
|
|
673
|
+
| matthyk | | fastify-plugin |
|
|
674
|
+
| mch-dsk | | fastify |
|
|
675
|
+
| mcollina | [❤️ sponsor](https://github.com/sponsors/mcollina) | ajv-compiler; avvio; csrf-protection; fastify; fastify-accepts; fastify-accepts-serializer; fastify-auth; fastify-autoload; fastify-awilix; fastify-basic-auth; fastify-bearer-auth; fastify-caching; fastify-circuit-breaker; fastify-cli; fastify-compress; fastify-cookie; fastify-cors; fastify-diagnostics-channel; fastify-elasticsearch; fastify-env; fastify-etag; fastify-express; fastify-flash; fastify-formbody; fastify-funky; fastify-helmet; fastify-http-proxy; fastify-jwt; fastify-kafka; fastify-leveldb; fastify-multipart; fastify-mysql; fastify-oauth2; fastify-passport; fastify-plugin; fastify-postgres; fastify-rate-limit; fastify-redis; fastify-reply-from; fastify-request-context; fastify-response-validation; fastify-routes; fastify-routes-stats; fastify-schedule; fastify-secure-session; fastify-static; fastify-swagger; fastify-swagger-ui; fastify-url-data; fastify-websocket; fastify-zipkin; fluent-json-schema; light-my-request; middie; point-of-view; proxy-addr; secure-json-parse; under-pressure |
|
|
676
|
+
| melroy89 | [❤️ sponsor](https://github.com/sponsors/melroy89) | under-pressure |
|
|
677
|
+
| metcoder95 | [❤️ sponsor](https://github.com/sponsors/metcoder95) | fastify-elasticsearch |
|
|
678
|
+
| mhamann | | fastify-cli |
|
|
679
|
+
| mihaur | | fastify-elasticsearch |
|
|
680
|
+
| mikesamm | | fastify |
|
|
681
|
+
| mikhael-abdallah | | secure-json-parse |
|
|
682
|
+
| miquelfire | [❤️ sponsor](https://github.com/sponsors/miquelfire) | fastify-routes |
|
|
683
|
+
| miraries | | fastify-swagger-ui |
|
|
684
|
+
| mohab-sameh | | fastify |
|
|
685
|
+
| monish001 | | fastify |
|
|
686
|
+
| moradebianchetti81 | | fastify |
|
|
687
|
+
| mouhannad-sh | | aws-lambda-fastify |
|
|
688
|
+
| multivoltage | | point-of-view |
|
|
689
|
+
| muya | [❤️ sponsor](https://github.com/sponsors/muya) | under-pressure |
|
|
690
|
+
| mweberxyz | | point-of-view |
|
|
691
|
+
| nflaig | | fastify |
|
|
692
|
+
| nickfla1 | | avvio |
|
|
693
|
+
| o-az | | process-warning |
|
|
694
|
+
| ojeytonwilliams | | csrf-protection |
|
|
695
|
+
| onosendi | | fastify-formbody |
|
|
696
|
+
| philippviereck | | fastify |
|
|
697
|
+
| pip77 | | fastify-mongodb |
|
|
698
|
+
| puskin94 | | fastify |
|
|
699
|
+
| remidewitte | | fastify |
|
|
700
|
+
| rozzilla | | fastify |
|
|
701
|
+
| samialdury | | fastify-cli |
|
|
702
|
+
| sknetl | | fastify-cors |
|
|
703
|
+
| sourcecodeit | | fastify |
|
|
704
|
+
| synapse | | env-schema |
|
|
705
|
+
| timursaurus | | secure-json-parse |
|
|
706
|
+
| tlhunter | | fastify |
|
|
707
|
+
| tlund101 | | fastify-rate-limit |
|
|
708
|
+
| ttshivers | | fastify-http-proxy |
|
|
709
|
+
| voxpelli | [❤️ sponsor](https://github.com/sponsors/voxpelli) | fastify |
|
|
710
|
+
| weixinwu | | fastify-cli |
|
|
711
|
+
| zetaraku | | fastify-cli |
|
|
712
|
+
|
|
@@ -316,7 +316,7 @@ based on a [route config option](../Reference/Routes.md#routes-options):
|
|
|
316
316
|
```js
|
|
317
317
|
fastify.register((instance, opts, done) => {
|
|
318
318
|
instance.decorate('util', (request, key, value) => { request[key] = value })
|
|
319
|
-
|
|
319
|
+
|
|
320
320
|
function handler(request, reply, done) {
|
|
321
321
|
instance.util(request, 'timestamp', new Date())
|
|
322
322
|
done()
|