fastify 5.8.5 → 5.10.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.
Files changed (126) hide show
  1. package/PROJECT_CHARTER.md +1 -1
  2. package/README.md +7 -10
  3. package/SECURITY.md +1 -1
  4. package/SPONSORS.md +6 -4
  5. package/build/build-validation.js +2 -2
  6. package/docs/Guides/Database.md +0 -28
  7. package/docs/Guides/Delay-Accepting-Requests.md +1 -1
  8. package/docs/Guides/Ecosystem.md +23 -9
  9. package/docs/Guides/Getting-Started.md +2 -2
  10. package/docs/Guides/Migration-Guide-V4.md +2 -2
  11. package/docs/Guides/Migration-Guide-V5.md +1 -1
  12. package/docs/Guides/Plugins-Guide.md +1 -1
  13. package/docs/Guides/Prototype-Poisoning.md +3 -3
  14. package/docs/Guides/Serverless.md +8 -15
  15. package/docs/Guides/Style-Guide.md +1 -1
  16. package/docs/Guides/Write-Plugin.md +1 -1
  17. package/docs/Reference/Encapsulation.md +27 -26
  18. package/docs/Reference/Errors.md +12 -4
  19. package/docs/Reference/HTTP2.md +10 -10
  20. package/docs/Reference/Hooks.md +5 -5
  21. package/docs/Reference/Index.md +14 -16
  22. package/docs/Reference/LTS.md +12 -13
  23. package/docs/Reference/Lifecycle.md +9 -8
  24. package/docs/Reference/Logging.md +47 -39
  25. package/docs/Reference/Middleware.md +21 -25
  26. package/docs/Reference/Principles.md +2 -2
  27. package/docs/Reference/Reply.md +6 -1
  28. package/docs/Reference/Request.md +29 -18
  29. package/docs/Reference/Routes.md +5 -2
  30. package/docs/Reference/Server.md +138 -11
  31. package/docs/Reference/Type-Providers.md +53 -9
  32. package/docs/Reference/TypeScript.md +3 -3
  33. package/docs/Reference/Validation-and-Serialization.md +15 -2
  34. package/docs/Reference/Warnings.md +11 -6
  35. package/eslint.config.js +7 -2
  36. package/fastify.d.ts +13 -3
  37. package/fastify.js +60 -31
  38. package/lib/content-type-parser.js +2 -0
  39. package/lib/content-type.js +34 -1
  40. package/lib/context.js +0 -3
  41. package/lib/decorate.js +11 -3
  42. package/lib/error-handler.js +10 -28
  43. package/lib/error-serializer.js +59 -59
  44. package/lib/errors.js +23 -1
  45. package/lib/four-oh-four.js +22 -19
  46. package/lib/handle-request.js +12 -5
  47. package/lib/log-controller.js +169 -0
  48. package/lib/logger-factory.js +25 -4
  49. package/lib/plugin-override.js +2 -1
  50. package/lib/plugin-utils.js +5 -5
  51. package/lib/reply.js +96 -50
  52. package/lib/req-id-gen-factory.js +4 -1
  53. package/lib/request.js +16 -6
  54. package/lib/route.js +47 -41
  55. package/lib/schema-controller.js +1 -1
  56. package/lib/schemas.js +37 -30
  57. package/lib/symbols.js +4 -2
  58. package/lib/validation.js +10 -13
  59. package/lib/warnings.js +22 -4
  60. package/package.json +15 -17
  61. package/scripts/validate-ecosystem-links.js +1 -0
  62. package/test/bundler/esbuild/package.json +1 -1
  63. package/test/close-pipelining.test.js +1 -2
  64. package/test/content-type.test.js +20 -0
  65. package/test/custom-http-server.test.js +38 -0
  66. package/test/decorator-instance-properties.test.js +63 -0
  67. package/test/diagnostics-channel/async-error-handler.test.js +74 -0
  68. package/test/genReqId.test.js +24 -0
  69. package/test/hooks.test.js +94 -0
  70. package/test/http-methods/get.test.js +1 -1
  71. package/test/http2/plain.test.js +135 -0
  72. package/test/http2/secure-with-fallback.test.js +1 -1
  73. package/test/https/https.test.js +1 -2
  74. package/test/internals/errors.test.js +31 -1
  75. package/test/internals/logger.test.js +322 -0
  76. package/test/internals/plugin.test.js +3 -1
  77. package/test/internals/reply.test.js +35 -4
  78. package/test/internals/request.test.js +37 -10
  79. package/test/internals/schema-controller-perf.test.js +33 -0
  80. package/test/logger/logging.test.js +57 -1
  81. package/test/logger/options.test.js +38 -1
  82. package/test/reply-error.test.js +1 -1
  83. package/test/reply-trailers.test.js +70 -0
  84. package/test/request-media-type.test.js +105 -0
  85. package/test/route-prefix.test.js +34 -0
  86. package/test/router-options.test.js +222 -11
  87. package/test/schema-serialization.test.js +108 -0
  88. package/test/schema-validation.test.js +24 -0
  89. package/test/scripts/validate-ecosystem-links.test.js +40 -57
  90. package/test/stream.4.test.js +2 -2
  91. package/test/throw.test.js +14 -0
  92. package/test/trust-proxy.test.js +70 -30
  93. package/test/types/content-type-parser.tst.ts +70 -0
  94. package/test/types/{decorate-request-reply.test-d.ts → decorate-request-reply.tst.ts} +4 -4
  95. package/test/types/{dummy-plugin.ts → dummy-plugin.mts} +1 -1
  96. package/test/types/errors.tst.ts +91 -0
  97. package/test/types/fastify.tst.ts +351 -0
  98. package/test/types/hooks.tst.ts +578 -0
  99. package/test/types/instance.tst.ts +597 -0
  100. package/test/types/{logger.test-d.ts → logger.tst.ts} +61 -62
  101. package/test/types/plugin.tst.ts +96 -0
  102. package/test/types/register.tst.ts +245 -0
  103. package/test/types/reply.tst.ts +297 -0
  104. package/test/types/request.tst.ts +199 -0
  105. package/test/types/route.tst.ts +576 -0
  106. package/test/types/{schema.test-d.ts → schema.tst.ts} +22 -22
  107. package/test/types/{serverFactory.test-d.ts → serverFactory.tst.ts} +4 -4
  108. package/test/types/tsconfig.json +9 -0
  109. package/test/types/{type-provider.test-d.ts → type-provider.tst.ts} +256 -250
  110. package/test/types/using.tst.ts +14 -0
  111. package/types/errors.d.ts +4 -0
  112. package/types/instance.d.ts +2 -0
  113. package/types/logger.d.ts +22 -0
  114. package/types/request.d.ts +23 -2
  115. package/test/types/content-type-parser.test-d.ts +0 -72
  116. package/test/types/errors.test-d.ts +0 -90
  117. package/test/types/fastify.test-d.ts +0 -352
  118. package/test/types/hooks.test-d.ts +0 -550
  119. package/test/types/import.ts +0 -2
  120. package/test/types/instance.test-d.ts +0 -588
  121. package/test/types/plugin.test-d.ts +0 -97
  122. package/test/types/register.test-d.ts +0 -237
  123. package/test/types/reply.test-d.ts +0 -254
  124. package/test/types/request.test-d.ts +0 -188
  125. package/test/types/route.test-d.ts +0 -553
  126. package/test/types/using.test-d.ts +0 -17
@@ -50,7 +50,7 @@ experience with the least overhead and a plugin architecture.
50
50
 
51
51
  Technical leadership for the projects within the [OpenJS Foundation][openjs
52
52
  foundation] is delegated to the projects through their project charters by the
53
- [OpenJS Foundation Cross-Project Council](https://openjsf.org/about/governance/)
53
+ [OpenJS Foundation Cross-Project Council](https://openjsf.org/governance)
54
54
  (CPC). In the case of the Fastify project, it is delegated to the [Fastify
55
55
  Collaborators](README.md#team). The OpenJS Foundation's business leadership is
56
56
  the Board of Directors (the "Board").
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <div align="center"> <a href="https://fastify.dev/">
2
2
  <img
3
- src="https://github.com/fastify/graphics/raw/HEAD/fastify-landscape-outlined.svg"
3
+ src="https://raw.githubusercontent.com/fastify/graphics/HEAD/fastify-landscape-outlined.svg"
4
4
  width="650"
5
5
  height="auto"
6
6
  />
@@ -15,7 +15,7 @@ CI](https://github.com/fastify/fastify/actions/workflows/package-manager-ci.yml/
15
15
  [![Web
16
16
  site](https://github.com/fastify/fastify/actions/workflows/website.yml/badge.svg?branch=main)](https://github.com/fastify/fastify/actions/workflows/website.yml)
17
17
  [![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
18
- [![CII Best Practices](https://bestpractices.coreinfrastructure.org/projects/7585/badge)](https://bestpractices.coreinfrastructure.org/projects/7585)
18
+ [![CII Best Practices](https://www.bestpractices.dev/projects/7585/badge)](https://www.bestpractices.dev/en/projects/7585/passing)
19
19
 
20
20
  </div>
21
21
 
@@ -27,7 +27,7 @@ version](https://img.shields.io/npm/v/fastify.svg?style=flat)](https://www.npmjs
27
27
  downloads](https://img.shields.io/npm/dm/fastify.svg?style=flat)](https://www.npmjs.com/package/fastify)
28
28
  [![Security Responsible
29
29
  Disclosure](https://img.shields.io/badge/Security-Responsible%20Disclosure-yellow.svg)](https://github.com/fastify/fastify/blob/main/SECURITY.md)
30
- [![Discord](https://img.shields.io/discord/725613461949906985)](https://discord.gg/fastify)
30
+ [![Discord](https://img.shields.io/discord/725613461949906985)](https://discord.com/invite/fastify)
31
31
  [![Contribute with Gitpod](https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod&color=blue)](https://gitpod.io/#https://github.com/fastify/fastify)
32
32
  [![Open Collective backers and sponsors](https://img.shields.io/opencollective/all/fastify)](https://github.com/sponsors/fastify#sponsors)
33
33
 
@@ -253,8 +253,8 @@ application. You should __always__ benchmark if performance matters to you.
253
253
  plugins.
254
254
  - [Live Examples](https://github.com/fastify/example) - Multirepo with a broad
255
255
  set of real working examples.
256
- - [Discord](https://discord.gg/D3FZYPy) - Join our discord server and chat with
257
- the maintainers.
256
+ - [Discord](https://discord.com/invite/D3FZYPy) - Join our discord server and
257
+ chat with the maintainers.
258
258
 
259
259
  ## Support
260
260
  Please visit [Fastify help](https://github.com/fastify/help) to view prior
@@ -312,7 +312,7 @@ listed in alphabetical order.
312
312
  * [__KaKa Ng__](https://github.com/climba03003),
313
313
  <https://www.npmjs.com/~climba03003>
314
314
  * [__Luis Orbaiceta__](https://github.com/luisorbaiceta),
315
- <https://x.com/luisorbai>, <https://www.npmjs.com/~luisorbaiceta>
315
+ <https://www.npmjs.com/~luisorbaiceta>
316
316
  * [__Maksim Sinik__](https://github.com/fox1t),
317
317
  <https://x.com/maksimsinik>, <https://www.npmjs.com/~fox1t>
318
318
  * [__Manuel Spigolon__](https://github.com/eomm),
@@ -383,7 +383,7 @@ active contributor's group.
383
383
  ## Hosted by
384
384
 
385
385
  [<img
386
- src="https://github.com/openjs-foundation/artwork/blob/main/openjs_foundation/openjs_foundation-logo-horizontal-color.png?raw=true"
386
+ src="https://raw.githubusercontent.com/openjs-foundation/artwork/main/openjs_foundation/openjs_foundation-logo-horizontal-color.png"
387
387
  width="250px;"/>](https://openjsf.org/projects)
388
388
 
389
389
  We are an [At-Large
@@ -402,9 +402,6 @@ This project is kindly sponsored by:
402
402
  - [NearForm](https://nearform.com)
403
403
  - [Platformatic](https://platformatic.dev)
404
404
 
405
- Past Sponsors:
406
- - [LetzDoIt](https://www.letzdoitapp.com/)
407
-
408
405
  This list includes all companies that support one or more team members
409
406
  in maintaining this project.
410
407
 
package/SECURITY.md CHANGED
@@ -71,7 +71,7 @@ Fastify falls under the [OpenJS CNA](https://cna.openjsf.org/).
71
71
  A CVE will be assigned as part of our responsible disclosure process.
72
72
 
73
73
  > ℹ️ Note:
74
- > Fastify's [HackerOne](https://hackerone.com/fastify) program is now closed.
74
+ > Fastify's HackerOne program is closed.
75
75
 
76
76
  ### Strict measures when reporting vulnerabilities
77
77
 
package/SPONSORS.md CHANGED
@@ -13,12 +13,14 @@ or [GitHub Sponsors](https://github.com/sponsors/fastify)!
13
13
 
14
14
  ## Tier 3
15
15
 
16
- - [Mercedes-Benz Group](https://github.com/mercedes-benz)
17
- - [Val Town, Inc.](https://opencollective.com/valtown)
18
16
  - [Handsontable - JavaScript Data Grid](https://handsontable.com/docs/react-data-grid/?utm_source=Fastify_GH&utm_medium=sponsorship&utm_campaign=library_sponsorship_2024)
19
17
  - [Lokalise - A Localization and Translation Software Tool](https://lokalise.com/?utm_source=Fastify_GH&utm_medium=sponsorship)
20
- - [TestMu AI](https://www.testmu.ai/)
18
+ - [Val Town](https://www.val.town/)
19
+ - [atagon GmbH](https://github.com/atagon-GmbH)
20
+ - [Photon](https://github.com/photon-hq)
21
21
 
22
22
  ## Tier 2
23
23
 
24
- _Be the first!_
24
+ - [Sent.dm](https://github.com/sentdm)
25
+ - [Süddeutsche Zeitung](https://github.com/sueddeutsche)
26
+ - [openclaw](https://github.com/openclaw)
@@ -32,7 +32,7 @@ const defaultInitOptions = {
32
32
  bodyLimit: 1024 * 1024, // 1 MiB
33
33
  caseSensitive: true,
34
34
  allowUnsafeRegex: false,
35
- disableRequestLogging: false,
35
+ disableRequestLogging: false, // TODO: remove it in v6
36
36
  ignoreTrailingSlash: false,
37
37
  ignoreDuplicateSlashes: false,
38
38
  maxParamLength: 100,
@@ -40,7 +40,7 @@ const defaultInitOptions = {
40
40
  onConstructorPoisoning: 'error',
41
41
  pluginTimeout: 10000,
42
42
  requestIdHeader: false,
43
- requestIdLogLabel: 'reqId',
43
+ requestIdLogLabel: 'reqId', // TODO: remove it in v6
44
44
  http2SessionTimeout: 72000, // 72 seconds
45
45
  exposeHeadRoutes: true,
46
46
  useSemicolonDelimiter: false,
@@ -149,34 +149,6 @@ fastify.listen({ port: 3000 }, err => {
149
149
  })
150
150
  ```
151
151
 
152
- ### [LevelDB](https://github.com/fastify/fastify-leveldb)
153
- Install the plugin by running `npm i @fastify/leveldb`
154
-
155
- *Usage:*
156
- ```javascript
157
- const fastify = require('fastify')()
158
-
159
- fastify.register(
160
- require('@fastify/leveldb'),
161
- { name: 'db' }
162
- )
163
-
164
- fastify.get('/foo', async function (req, reply) {
165
- const val = await this.level.db.get(req.query.key)
166
- return val
167
- })
168
-
169
- fastify.post('/foo', async function (req, reply) {
170
- await this.level.db.put(req.body.key, req.body.value)
171
- return { status: 'ok' }
172
- })
173
-
174
- fastify.listen({ port: 3000 }, err => {
175
- if (err) throw err
176
- console.log(`server listening on ${fastify.server.address().port}`)
177
- })
178
- ```
179
-
180
152
  ### Writing plugin for a database library
181
153
  We could write a plugin for a database
182
154
  library too (e.g. Knex, Prisma, or TypeORM).
@@ -447,7 +447,7 @@ served until we have everything ready. And there's more: we fail **FAST** and
447
447
  have the possibility of giving the customer meaningful information, like how
448
448
  long they should wait before retrying the request. Going even further, by
449
449
  issuing a [`503` status
450
- code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) we're
450
+ code](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/503) we're
451
451
  signaling to our infrastructure components (namely load balancers) that we're
452
452
  still not ready to take incoming requests and they should redirect traffic to
453
453
  other instances, if available. Additionally, we are providing a `Retry-After`
@@ -66,8 +66,6 @@ section.
66
66
  Fastify, internally uses [fast-jwt](https://github.com/nearform/fast-jwt).
67
67
  - [`@fastify/kafka`](https://github.com/fastify/fastify-kafka) Plugin to interact
68
68
  with Apache Kafka.
69
- - [`@fastify/leveldb`](https://github.com/fastify/fastify-leveldb) Plugin to
70
- share a common LevelDB connection across Fastify.
71
69
  - [`@fastify/middie`](https://github.com/fastify/middie) Middleware engine for
72
70
  Fastify.
73
71
  - [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
@@ -146,7 +144,7 @@ section.
146
144
  - [`@fastify/view`](https://github.com/fastify/point-of-view) Templates
147
145
  rendering (_ejs, pug, handlebars, marko_) plugin support for Fastify.
148
146
  - [`@fastify/vite`](https://github.com/fastify/fastify-vite) Integration with
149
- [Vite](https://vitejs.dev/), allows for serving SPA/MPA/SSR Vite applications.
147
+ [Vite](https://vite.dev/), allows for serving SPA/MPA/SSR Vite applications.
150
148
  - [`@fastify/websocket`](https://github.com/fastify/fastify-websocket) WebSocket
151
149
  support for Fastify. Built upon [ws](https://github.com/websockets/ws).
152
150
  - [`@fastify/zipkin`](https://github.com/fastify/fastify-zipkin) Plugin
@@ -198,7 +196,7 @@ section.
198
196
  Run REST APIs and other web applications using your existing Node.js
199
197
  application framework (Express, Koa, Hapi and Fastify), on top of AWS Lambda,
200
198
  Huawei and many other clouds.
201
- - [`@hey-api/openapi-ts`](https://heyapi.dev/openapi-ts/plugins/fastify)
199
+ - [`@hey-api/openapi-ts`](https://heyapi.dev/docs/openapi/typescript/plugins/fastify)
202
200
  The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more.
203
201
  - [`@immobiliarelabs/fastify-metrics`](https://github.com/immobiliare/fastify-metrics)
204
202
  Minimalistic and opinionated plugin that collects usage/process metrics and
@@ -206,6 +204,8 @@ section.
206
204
  - [`@inaiat/fastify-papr`](https://github.com/inaiat/fastify-papr)
207
205
  A plugin to integrate [Papr](https://github.com/plexinc/papr),
208
206
  the MongoDB ORM for TypeScript & MongoDB, with Fastify.
207
+ - [`@inferdi/fastify`](https://github.com/inferdi/inferdi/tree/main/packages/fastify)
208
+ Type-safe dependency injection support for Fastify, powered by [InferDI](https://github.com/inferdi/inferdi).
209
209
  - [`@jerome1337/fastify-enforce-routes-pattern`](https://github.com/Jerome1337/fastify-enforce-routes-pattern)
210
210
  A Fastify plugin that enforces naming pattern for routes path.
211
211
  - [`@joggr/fastify-prisma`](https://github.com/joggrdocs/fastify-prisma)
@@ -232,6 +232,12 @@ section.
232
232
  Plugin to generate routes automatically with valid json content
233
233
  - [`@scalar/fastify-api-reference`](https://github.com/scalar/scalar/tree/main/integrations/fastify)
234
234
  Beautiful OpenAPI/Swagger API references for Fastify
235
+ - [`@stitchapi/fastify`](https://github.com/rejifald/StitchAPI/tree/main/packages/fastify)
236
+ Decorate the app/request with a StitchAPI seam — request-scoped principal, SSE
237
+ streaming, error mapping, and a Pino-logger bridge.
238
+ - [`@thecodepace/fastify-http-query`](https://github.com/TheCodePace/fastify-http-query)
239
+ Fastify plugin enabling the HTTP `QUERY` method (a safe, idempotent, cacheable
240
+ method with a body).
235
241
  - [`@trubavuong/fastify-seaweedfs`](https://github.com/trubavuong/fastify-seaweedfs)
236
242
  SeaweedFS for Fastify
237
243
  - [`@yeliex/fastify-problem-details`](https://github.com/yeliex/fastify-problem-details)
@@ -281,10 +287,13 @@ section.
281
287
  MySQL plugin with auto SQL injection attack prevention.
282
288
  - [`fastify-at-postgres`](https://github.com/mateonunez/fastify-at-postgres) Fastify
283
289
  Postgres plugin with auto SQL injection attack prevention.
290
+ - [`fastify-ata`](https://github.com/ata-core/fastify-ata) Use
291
+ [`ata-validator`](https://github.com/ata-core/ata-validator) as the JSON Schema
292
+ validator, keeping Fastify's default error shape.
284
293
  - [`fastify-auth0-verify`](https://github.com/nearform/fastify-auth0-verify):
285
294
  Auth0 verification plugin for Fastify, internally uses
286
- [fastify-jwt](https://npm.im/fastify-jwt) and
287
- [jsonwebtoken](https://npm.im/jsonwebtoken).
295
+ [fastify-jwt](https://www.npmjs.com/package/fastify-jwt) and
296
+ [jsonwebtoken](https://www.npmjs.com/package/jsonwebtoken).
288
297
  - [`fastify-autoroutes`](https://github.com/GiovanniCardamone/fastify-autoroutes)
289
298
  Plugin to scan and load routes based on filesystem path from a custom
290
299
  directory.
@@ -384,7 +393,7 @@ section.
384
393
  - [`fastify-formidable`](https://github.com/climba03003/fastify-formidable)
385
394
  Handy plugin to provide multipart support and fastify-swagger integration.
386
395
  - [`fastify-gcloud-trace`](https://github.com/mkinoshi/fastify-gcloud-trace)
387
- [Google Cloud Trace API](https://cloud.google.com/trace/docs/reference)
396
+ [Google Cloud Trace API](https://docs.cloud.google.com/trace/docs/reference)
388
397
  Connector for Fastify.
389
398
  - [`fastify-get-head`](https://github.com/MetCoder95/fastify-get-head) Small
390
399
  plugin to set a new HEAD route handler for each GET route previously
@@ -539,6 +548,9 @@ middlewares into Fastify plugins
539
548
  OSM plugin to run overpass queries by OpenStreetMap.
540
549
  - [`fastify-override`](https://github.com/matthyk/fastify-override)
541
550
  Fastify plugin to override decorators, plugins and hooks for testing purposes
551
+ - [`fastify-param-schema-validation`](https://github.com/Player1205/fastify-param-schema-validation)
552
+ Enforce strict parameter definitions in route validation schemas
553
+ to prevent missing parameter validation.
542
554
  - [`fastify-passkit-webservice`](https://github.com/alexandercerutti/fastify-passkit-webservice)
543
555
  A set of Fastify plugins to integrate Apple Wallet Web Service specification
544
556
  - [`fastify-peekaboo`](https://github.com/simone-sanfratello/fastify-peekaboo)
@@ -552,7 +564,7 @@ middlewares into Fastify plugins
552
564
  to handle i18n using
553
565
  [node-polyglot](https://www.npmjs.com/package/node-polyglot).
554
566
  - [`fastify-postgraphile`](https://github.com/alemagio/fastify-postgraphile)
555
- Plugin to integrate [PostGraphile](https://www.graphile.org/postgraphile/) in
567
+ Plugin to integrate [PostGraphile](https://postgraphile.org/postgraphile/4/) in
556
568
  a Fastify project.
557
569
  - [`fastify-postgres-dot-js`](https://github.com/kylerush/fastify-postgresjs) Fastify
558
570
  PostgreSQL connection plugin that uses [Postgres.js](https://github.com/porsager/postgres).
@@ -670,7 +682,7 @@ middlewares into Fastify plugins
670
682
  multiple subdomains to the same IP address, while running different servers on
671
683
  the same machine).
672
684
  - [`fastify-vue-plugin`](https://github.com/TheNoim/fastify-vue)
673
- [Nuxt.js](https://nuxtjs.org) plugin for Fastify. Control the routes nuxt
685
+ [Nuxt.js](https://nuxt.com) plugin for Fastify. Control the routes nuxt
674
686
  should use.
675
687
  - [`fastify-wamp-router`](https://github.com/lependu/fastify-wamp-router) Web
676
688
  Application Messaging Protocol router for Fastify.
@@ -718,6 +730,8 @@ middlewares into Fastify plugins
718
730
  generator by directory structure.
719
731
  - [`fastify-flux`](https://github.com/Jnig/fastify-flux) Tool for building
720
732
  Fastify APIs using decorators and convert Typescript interface to JSON Schema.
733
+ - [`fastify-intlayer`](https://intlayer.org/doc/environment/fastify)
734
+ i18n solution for error handling, email template
721
735
  - [`jeasx`](https://www.jeasx.dev)
722
736
  A flexible server-rendering framework built on Fastify
723
737
  that leverages asynchronous JSX to simplify web development.
@@ -605,10 +605,10 @@ npm start
605
605
 
606
606
  - Slides
607
607
  - [Take your HTTP server to ludicrous
608
- speed](https://mcollina.github.io/take-your-http-server-to-ludicrous-speed)
608
+ speed](https://mcollina.github.io/take-your-http-server-to-ludicrous-speed/)
609
609
  by [@mcollina](https://github.com/mcollina)
610
610
  - [What if I told you that HTTP can be
611
- fast](https://delvedor.github.io/What-if-I-told-you-that-HTTP-can-be-fast)
611
+ fast](https://delvedor.dev/What-if-I-told-you-that-HTTP-can-be-fast/)
612
612
  by [@delvedor](https://github.com/delvedor)
613
613
 
614
614
  - Videos
@@ -10,7 +10,7 @@ work after upgrading.
10
10
  ### Fastify v4 Codemods
11
11
 
12
12
  To help with the upgrade, we’ve worked with the team at
13
- [Codemod](https://github.com/codemod-com/codemod) to
13
+ [Codemod](https://github.com/codemod/codemod) to
14
14
  publish codemods that will automatically update your code to many of
15
15
  the new APIs and patterns in Fastify v4.
16
16
 
@@ -264,4 +264,4 @@ Into:
264
264
  Fastify now supports the [HTTP Trailer] response headers.
265
265
 
266
266
 
267
- [HTTP Trailer]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Trailer
267
+ [HTTP Trailer]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Trailer
@@ -105,7 +105,7 @@ const fastify = require('fastify')({
105
105
  Starting with v5, Fastify instances will no longer default to supporting the use
106
106
  of semicolon delimiters in the query string as they did in v4.
107
107
  This is due to it being non-standard
108
- behavior and not adhering to [RFC 3986](https://www.rfc-editor.org/rfc/rfc3986#section-3.4).
108
+ behavior and not adhering to [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986#section-3.4).
109
109
 
110
110
  If you still wish to use semicolons as delimiters, you can do so by
111
111
  setting `useSemicolonDelimiter: true` in the server configuration.
@@ -507,7 +507,7 @@ section of our documentation!
507
507
 
508
508
  If you want to see some real-world examples, check out:
509
509
  - [`@fastify/view`](https://github.com/fastify/point-of-view) Templates
510
- rendering (*ejs, pug, handlebars, marko*) plugin support for Fastify.
510
+ rendering (*ejs, pug, handlebars*) plugin support for Fastify.
511
511
  - [`@fastify/mongodb`](https://github.com/fastify/fastify-mongodb) Fastify
512
512
  MongoDB connection plugin, with this you can share the same MongoDB connection
513
513
  pool in every part of your server.
@@ -232,7 +232,7 @@ itself), it is much harder getting it fixed.
232
232
 
233
233
  The first question people ask once a security issue is found is if there is
234
234
  going to be a CVE published. A CVE — Common Vulnerabilities and Exposures — is a
235
- [database](https://cve.mitre.org/) of known security issues. It is a critical
235
+ [database](https://www.cve.org/) of known security issues. It is a critical
236
236
  component of web security. The benefit of publishing a CVE is that it
237
237
  immediately triggers alarms and informs and often breaks automated builds until
238
238
  the issue is resolved.
@@ -376,8 +376,8 @@ source maintainers.
376
376
  Because this work is important, I decided to try and make it not just
377
377
  financially sustainable but to grow and expand it. There is so much to improve.
378
378
  This is exactly what motivates me to implement the new [commercial licensing
379
- plan](https://web.archive.org/web/20190201220503/https://hueniverse.com/on-hapi-licensing-a-preview-f982662ee898)
379
+ plan](https://web.archive.org/web/20190201220503/https://hueniverse.com/on-hapi-licensing-a-preview-f982662ee898?gi=b54e9a75bac6)
380
380
  coming in March. You can read more about it
381
- [here](https://web.archive.org/web/20190201220503/https://hueniverse.com/on-hapi-licensing-a-preview-f982662ee898).
381
+ [here](https://web.archive.org/web/20190201220503/https://hueniverse.com/on-hapi-licensing-a-preview-f982662ee898?gi=b54e9a75bac6).
382
382
 
383
383
 
@@ -109,13 +109,6 @@ signature to be used as a lambda `handler` function. This way all the incoming
109
109
  events (API Gateway requests) are passed to the `proxy` function of
110
110
  [@fastify/aws-lambda](https://github.com/fastify/aws-lambda-fastify).
111
111
 
112
- #### Example
113
-
114
- An example deployable with
115
- [claudia.js](https://claudiajs.com/tutorials/serverless-express.html) can be
116
- found
117
- [here](https://github.com/claudiajs/example-projects/tree/master/fastify-app-lambda).
118
-
119
112
  ### Considerations
120
113
 
121
114
  - API Gateway does not support streams yet, so you are not able to handle
@@ -126,7 +119,7 @@ found
126
119
  #### Beyond API Gateway
127
120
 
128
121
  If you need to integrate with more AWS services, take a look at
129
- [@h4ad/serverless-adapter](https://viniciusl.com.br/serverless-adapter/docs/main/frameworks/fastify)
122
+ [@h4ad/serverless-adapter](https://serverless-adapter.viniciusl.com.br/docs/main/frameworks/fastify)
130
123
  on Fastify to find out how to integrate.
131
124
 
132
125
  ## Genezio
@@ -134,7 +127,7 @@ on Fastify to find out how to integrate.
134
127
  [Genezio](https://genezio.com/) is a platform designed to simplify the deployment
135
128
  of serverless applications to the cloud.
136
129
 
137
- [Genezio has a dedicated guide for deploying a Fastify application.](https://genezio.com/docs/frameworks/fastify/)
130
+ [Genezio has a dedicated guide for deploying a Fastify application.](https://deployapps.dev/docs/frameworks/fastify/)
138
131
 
139
132
  ## Google Cloud Functions
140
133
 
@@ -265,7 +258,7 @@ curl -X POST https://$GOOGLE_REGION-$GOOGLE_PROJECT.cloudfunctions.net/me \
265
258
 
266
259
  ### References
267
260
  - [Google Cloud Functions - Node.js Quickstart
268
- ](https://cloud.google.com/functions/docs/quickstart-nodejs)
261
+ ](https://docs.cloud.google.com/run/docs/quickstarts/functions/deploy-functions-gcloud)
269
262
 
270
263
  ## Google Firebase Functions
271
264
 
@@ -403,7 +396,7 @@ the way you would write your Fastify app normally.
403
396
 
404
397
  *Follow the steps below to deploy to Google Cloud Run if you are already
405
398
  familiar with gcloud or just follow their
406
- [quickstart](https://cloud.google.com/run/docs/quickstarts/build-and-deploy)*.
399
+ [quickstart](https://docs.cloud.google.com/run/docs/quickstarts)*.
407
400
 
408
401
  ### Adjust Fastify server
409
402
 
@@ -451,9 +444,9 @@ You can add any valid `Dockerfile` that packages and runs a Node app. A basic
451
444
  docs](https://github.com/knative/docs/blob/2d654d1fd6311750cc57187a86253c52f273d924/docs/serving/samples/hello-world/helloworld-nodejs/Dockerfile).
452
445
 
453
446
  ```Dockerfile
454
- # Use the official Node.js 10 image.
447
+ # Use the official Node.js LTS image.
455
448
  # https://hub.docker.com/_/node
456
- FROM node:10
449
+ FROM node:lts
457
450
 
458
451
  # Create and change to the app directory.
459
452
  WORKDIR /usr/src/app
@@ -590,7 +583,7 @@ Then it should work fine.
590
583
 
591
584
  [Vercel](https://vercel.com) fully supports deploying Fastify applications.
592
585
  Additionally, with Vercel's
593
- [Fluid compute](https://vercel.com/docs/functions/fluid-compute), you can combine
586
+ [Fluid compute](https://vercel.com/docs/fluid-compute), you can combine
594
587
  server-like concurrency with the autoscaling properties of traditional
595
588
  serverless functions.
596
589
 
@@ -598,7 +591,7 @@ Get started with the
598
591
  [Fastify template on Vercel](
599
592
  https://vercel.com/templates/backend/fastify-on-vercel).
600
593
 
601
- [Fluid compute](https://vercel.com/docs/functions/fluid-compute) currently
594
+ [Fluid compute](https://vercel.com/docs/fluid-compute) currently
602
595
  requires an explicit opt-in. Learn more about enabling Fluid compute
603
596
  [here](
604
597
  https://vercel.com/docs/fluid-compute#enabling-fluid-compute).
@@ -13,7 +13,7 @@ This guide is for anyone who loves to build with Fastify or wants to contribute
13
13
  to our documentation. You do not need to be an expert in writing technical
14
14
  documentation. This guide is here to help you.
15
15
 
16
- Visit the [contribute](https://fastify.dev/contribute) page on our website or
16
+ Visit the [contribute](https://fastify.dev/contribute/) page on our website or
17
17
  read the
18
18
  [CONTRIBUTING.md](https://github.com/fastify/fastify/blob/main/CONTRIBUTING.md)
19
19
  file on GitHub to join our Open Source folks.
@@ -53,7 +53,7 @@ Always put an example file in your repository. Examples are very helpful for
53
53
  users and give a very fast way to test your plugin. Your users will be grateful.
54
54
 
55
55
  ## Test
56
- A plugin **must** be thoroughly tested to verify that is working properly.
56
+ A plugin **must** be thoroughly tested to verify that it is working properly.
57
57
 
58
58
  A plugin without tests will not be accepted to the ecosystem list. A lack of
59
59
  tests does not inspire trust nor guarantee that the code will continue to work
@@ -51,8 +51,8 @@ fastify.register(async function authenticatedContext (childServer) {
51
51
  childServer.route({
52
52
  path: '/one',
53
53
  method: 'GET',
54
- handler (request, response) {
55
- response.send({
54
+ handler (request, reply) {
55
+ reply.send({
56
56
  answer: request.answer,
57
57
  // request.foo will be undefined as it is only defined in publicContext
58
58
  foo: request.foo,
@@ -69,8 +69,8 @@ fastify.register(async function publicContext (childServer) {
69
69
  childServer.route({
70
70
  path: '/two',
71
71
  method: 'GET',
72
- handler (request, response) {
73
- response.send({
72
+ handler (request, reply) {
73
+ reply.send({
74
74
  answer: request.answer,
75
75
  foo: request.foo,
76
76
  // request.bar will be undefined as it is only defined in grandchildContext
@@ -85,8 +85,8 @@ fastify.register(async function publicContext (childServer) {
85
85
  grandchildServer.route({
86
86
  path: '/three',
87
87
  method: 'GET',
88
- handler (request, response) {
89
- response.send({
88
+ handler (request, reply) {
89
+ reply.send({
90
90
  answer: request.answer,
91
91
  foo: request.foo,
92
92
  bar: request.bar
@@ -114,12 +114,12 @@ original diagram:
114
114
  To see this, start the server and issue requests:
115
115
 
116
116
  ```sh
117
- # curl -H 'authorization: Bearer abc123' http://127.0.0.1:8000/one
118
- {"answer":42}
119
- # curl http://127.0.0.1:8000/two
120
- {"answer":42,"foo":"foo"}
121
- # curl http://127.0.0.1:8000/three
122
- {"answer":42,"foo":"foo","bar":"bar"}
117
+ curl -H 'authorization: Bearer abc123' http://127.0.0.1:8000/one
118
+ # {"answer":42}
119
+ curl http://127.0.0.1:8000/two
120
+ # {"answer":42,"foo":"foo"}
121
+ curl http://127.0.0.1:8000/three
122
+ # {"answer":42,"foo":"foo","bar":"bar"}
123
123
  ```
124
124
 
125
125
  [bearer]: https://github.com/fastify/fastify-bearer-auth
@@ -127,13 +127,14 @@ To see this, start the server and issue requests:
127
127
  ## Sharing Between Contexts
128
128
  <a id="shared-context"></a>
129
129
 
130
- Each context in the prior example inherits _only_ from its parent contexts. Parent
131
- contexts cannot access entities within their descendant contexts. If needed,
132
- encapsulation can be broken using [fastify-plugin][fastify-plugin], making
133
- anything registered in a descendant context available to the parent context.
130
+ Each context in the previous example inherits _only_ from its parent contexts.
131
+ Parent contexts cannot access entities within their descendant contexts.
132
+ If needed, encapsulation can be broken using [fastify-plugin][fastify-plugin],
133
+ making anything registered in a descendant context available
134
+ to the parent context.
134
135
 
135
- To allow `publicContext` access to the `bar` decorator in `grandchildContext`,
136
- rewrite the code as follows:
136
+ To allow `publicContext` to access the `bar` decorator from `grandchildContext`,
137
+ update the code as follows:
137
138
 
138
139
  ```js
139
140
  'use strict'
@@ -151,8 +152,8 @@ fastify.register(async function publicContext (childServer) {
151
152
  childServer.route({
152
153
  path: '/two',
153
154
  method: 'GET',
154
- handler (request, response) {
155
- response.send({
155
+ handler (request, reply) {
156
+ reply.send({
156
157
  answer: request.answer,
157
158
  foo: request.foo,
158
159
  bar: request.bar
@@ -168,8 +169,8 @@ fastify.register(async function publicContext (childServer) {
168
169
  grandchildServer.route({
169
170
  path: '/three',
170
171
  method: 'GET',
171
- handler (request, response) {
172
- response.send({
172
+ handler (request, reply) {
173
+ reply.send({
173
174
  answer: request.answer,
174
175
  foo: request.foo,
175
176
  bar: request.bar
@@ -185,10 +186,10 @@ fastify.listen({ port: 8000 })
185
186
  Restarting the server and re-issuing the requests for `/two` and `/three`:
186
187
 
187
188
  ```sh
188
- # curl http://127.0.0.1:8000/two
189
- {"answer":42,"foo":"foo","bar":"bar"}
190
- # curl http://127.0.0.1:8000/three
191
- {"answer":42,"foo":"foo","bar":"bar"}
189
+ curl http://127.0.0.1:8000/two
190
+ # {"answer":42,"foo":"foo","bar":"bar"}
191
+ curl http://127.0.0.1:8000/three
192
+ # {"answer":42,"foo":"foo","bar":"bar"}
192
193
  ```
193
194
 
194
195
  [fastify-plugin]: https://github.com/fastify/fastify-plugin