fastify 4.26.2 → 4.27.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 (61) hide show
  1. package/.taprc +1 -0
  2. package/README.md +4 -0
  3. package/SPONSORS.md +1 -1
  4. package/docs/Guides/Database.md +2 -2
  5. package/docs/Guides/Delay-Accepting-Requests.md +1 -1
  6. package/docs/Guides/Detecting-When-Clients-Abort.md +6 -4
  7. package/docs/Guides/Ecosystem.md +21 -11
  8. package/docs/Guides/Getting-Started.md +2 -0
  9. package/docs/Guides/Plugins-Guide.md +1 -1
  10. package/docs/Guides/Prototype-Poisoning.md +1 -1
  11. package/docs/Reference/Errors.md +2 -3
  12. package/docs/Reference/Hooks.md +5 -3
  13. package/docs/Reference/LTS.md +32 -20
  14. package/docs/Reference/Logging.md +1 -1
  15. package/docs/Reference/Reply.md +3 -3
  16. package/docs/Reference/Request.md +2 -2
  17. package/docs/Reference/Routes.md +3 -2
  18. package/docs/Reference/Server.md +11 -5
  19. package/docs/Reference/Type-Providers.md +10 -4
  20. package/docs/Reference/TypeScript.md +25 -24
  21. package/docs/Reference/Validation-and-Serialization.md +1 -1
  22. package/fastify.js +3 -4
  23. package/lib/error-handler.js +34 -21
  24. package/lib/fourOhFour.js +5 -3
  25. package/lib/handleRequest.js +2 -1
  26. package/lib/httpMethods.js +3 -1
  27. package/lib/wrapThenable.js +2 -0
  28. package/package.json +3 -3
  29. package/test/404s.test.js +2 -2
  30. package/test/500s.test.js +32 -0
  31. package/test/close.test.js +1 -1
  32. package/test/encapsulated-error-handler.test.js +1 -1
  33. package/test/esm/errorCodes.test.mjs +10 -0
  34. package/test/esm/named-exports.mjs +1 -0
  35. package/test/esm/other.mjs +1 -0
  36. package/test/esm/plugin.mjs +1 -0
  37. package/test/hooks.test.js +2 -2
  38. package/test/internals/handleRequest.test.js +2 -2
  39. package/test/lock.test.js +43 -10
  40. package/test/logger/instantiation.test.js +1 -1
  41. package/test/logger/logging.test.js +37 -16
  42. package/test/logger/options.test.js +1 -1
  43. package/test/mkcalendar.test.js +165 -0
  44. package/test/propfind.test.js +40 -8
  45. package/test/proppatch.test.js +48 -18
  46. package/test/report.test.js +161 -0
  47. package/test/schema-examples.test.js +1 -1
  48. package/test/schema-feature.test.js +6 -6
  49. package/test/schema-serialization.test.js +2 -2
  50. package/test/schema-special-usage.test.js +1 -1
  51. package/test/skip-reply-send.test.js +1 -1
  52. package/test/stream.5.test.js +2 -2
  53. package/test/types/instance.test-d.ts +1 -1
  54. package/test/types/reply.test-d.ts +2 -2
  55. package/test/types/request.test-d.ts +2 -2
  56. package/test/types/type-provider.test-d.ts +7 -3
  57. package/types/reply.d.ts +6 -4
  58. package/types/request.d.ts +2 -2
  59. package/types/type-provider.d.ts +1 -1
  60. package/types/utils.d.ts +1 -1
  61. /package/test/esm/{esm.mjs → esm.test.mjs} +0 -0
package/.taprc CHANGED
@@ -8,3 +8,4 @@ node-arg: --allow-natives-syntax
8
8
 
9
9
  files:
10
10
  - 'test/**/*.test.js'
11
+ - 'test/**/*.test.mjs'
package/README.md CHANGED
@@ -125,6 +125,7 @@ yarn add fastify
125
125
 
126
126
  // ESM
127
127
  import Fastify from 'fastify'
128
+
128
129
  const fastify = Fastify({
129
130
  logger: true
130
131
  })
@@ -150,6 +151,7 @@ with async-await:
150
151
  ```js
151
152
  // ESM
152
153
  import Fastify from 'fastify'
154
+
153
155
  const fastify = Fastify({
154
156
  logger: true
155
157
  })
@@ -323,6 +325,8 @@ listed in alphabetical order.
323
325
  <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>
324
326
  * [__Aras Abbasi__](https://github.com/uzlopak),
325
327
  <https://www.npmjs.com/~uzlopak>
328
+ * [__Gürgün Dayıoğlu__](https://github.com/gurgunday),
329
+ <https://www.npmjs.com/~gurgunday>
326
330
 
327
331
  ### Fastify Plugins team
328
332
  * [__Matteo Collina__](https://github.com/mcollina),
package/SPONSORS.md CHANGED
@@ -13,7 +13,7 @@ _Be the first!_
13
13
 
14
14
  ## Tier 3
15
15
 
16
- _Be the first!_
16
+ - [Mercedes-Benz Group](https://github.com/mercedes-benz)
17
17
 
18
18
  ## Tier 2
19
19
 
@@ -237,14 +237,14 @@ development. Migrations provide a repeatable and testable way to modify a
237
237
  database's schema and prevent data loss.
238
238
 
239
239
  As stated at the beginning of the guide, Fastify is database agnostic and any
240
- NodeJS database migration tool can be used with it. We will give an example of
240
+ Node.js database migration tool can be used with it. We will give an example of
241
241
  using [Postgrator](https://www.npmjs.com/package/postgrator) which has support
242
242
  for Postgres, MySQL, SQL Server and SQLite. For MongoDB migrations, please check
243
243
  [migrate-mongo](https://www.npmjs.com/package/migrate-mongo).
244
244
 
245
245
  #### [Postgrator](https://www.npmjs.com/package/postgrator)
246
246
 
247
- Postgrator is NodeJS SQL migration tool that uses a directory of SQL scripts to
247
+ Postgrator is Node.js SQL migration tool that uses a directory of SQL scripts to
248
248
  alter the database schema. Each file an migrations folder need to follow the
249
249
  pattern: ` [version].[action].[optional-description].sql`.
250
250
 
@@ -49,7 +49,7 @@ That will be achieved by wrapping into a custom plugin two main features:
49
49
 
50
50
  1. the mechanism for authenticating with the provider
51
51
  [decorating](../Reference/Decorators.md) the `fastify` object with the
52
- authentication key (`magicKey` from here onwards)
52
+ authentication key (`magicKey` from here onward)
53
53
  1. the mechanism for denying requests that would, otherwise, fail
54
54
 
55
55
  ### Hands-on
@@ -87,10 +87,12 @@ of `{ ok: true }`.
87
87
  - Logic that triggers in the hook when the request is closed.
88
88
  - Logging that occurs when the closed request property `aborted` is true.
89
89
 
90
- In the request close event, you should examine the diff between a successful
91
- request and one aborted by the client to determine the best property for your
92
- use case. You can find details about request properties in the
93
- [NodeJS documentation](https://nodejs.org/api/http.html).
90
+ Whilst the `aborted` property has been deprecated, `destroyed` is not a
91
+ suitable replacement as the
92
+ [Node.js documentation suggests](https://nodejs.org/api/http.html#requestaborted).
93
+ A request can be `destroyed` for various reasons, such as when the server closes
94
+ the connection. The `aborted` property is still the most reliable way to detect
95
+ when a client intentionally aborts a request.
94
96
 
95
97
  You can also perform this logic outside of a hook, directly in a specific route.
96
98
 
@@ -185,7 +185,7 @@ section.
185
185
  - [`@fastify-userland/typeorm-query-runner`](https://github.com/fastify-userland/typeorm-query-runner)
186
186
  Fastify typeorm QueryRunner plugin
187
187
  - [`@gquittet/graceful-server`](https://github.com/gquittet/graceful-server)
188
- Tiny (~5k), Fast, KISS, and dependency-free Node.JS library to make your
188
+ Tiny (~5k), Fast, KISS, and dependency-free Node.js library to make your
189
189
  Fastify API graceful.
190
190
  - [`@h4ad/serverless-adapter`](https://github.com/H4ad/serverless-adapter)
191
191
  Run REST APIs and other web applications using your existing Node.js
@@ -222,6 +222,8 @@ section.
222
222
  API key management solution.
223
223
  - [`arecibo`](https://github.com/nucleode/arecibo) Fastify ping responder for
224
224
  Kubernetes Liveness and Readiness Probes.
225
+ - [`aws-xray-sdk-fastify`](https://github.com/aws/aws-xray-sdk-node/tree/master/sdk_contrib/fastify)
226
+ A Fastify plugin to log requests and subsegments through AWSXray.
225
227
  - [`cls-rtracer`](https://github.com/puzpuzpuz/cls-rtracer) Fastify middleware
226
228
  for CLS-based request ID generation. An out-of-the-box solution for adding
227
229
  request IDs into your logs.
@@ -247,9 +249,12 @@ section.
247
249
  [`@angular/platform-server`](https://github.com/angular/angular/tree/master/packages/platform-server)
248
250
  for Fastify
249
251
  - [`fastify-api-key`](https://github.com/arkerone/fastify-api-key) Fastify
250
- plugin to authenticate HTTP requests based on api key and signature
252
+ plugin to authenticate HTTP requests based on API key and signature
251
253
  - [`fastify-appwrite`](https://github.com/Dev-Manny/fastify-appwrite) Fastify
252
254
  Plugin for interacting with Appwrite server.
255
+ - [`fastify-asyncforge`](https://github.com/mcollina/fastify-asyncforge) Plugin
256
+ to access Fastify instance, logger, request and reply from Node.js [Async
257
+ Local Storage](https://nodejs.org/api/async_context.html#class-asynclocalstorage).
253
258
  - [`fastify-at-mysql`](https://github.com/mateonunez/fastify-at-mysql) Fastify
254
259
  MySQL plugin with auto SQL injection attack prevention.
255
260
  - [`fastify-at-postgres`](https://github.com/mateonunez/fastify-at-postgres) Fastify
@@ -288,7 +293,7 @@ section.
288
293
  - [`fastify-bugsnag`](https://github.com/ZigaStrgar/fastify-bugsnag) Fastify plugin
289
294
  to add support for [Bugsnag](https://www.bugsnag.com/) error reporting.
290
295
  - [`fastify-cacheman`](https://gitlab.com/aalfiann/fastify-cacheman)
291
- Small and efficient cache provider for Node.JS with In-memory, File, Redis
296
+ Small and efficient cache provider for Node.js with In-memory, File, Redis
292
297
  and MongoDB engines for Fastify
293
298
  - [`fastify-casbin`](https://github.com/nearform/fastify-casbin) Casbin support
294
299
  for Fastify.
@@ -304,9 +309,7 @@ section.
304
309
  - [`fastify-cloudflare-turnstile`](https://github.com/112RG/fastify-cloudflare-turnstile)
305
310
  Fastify plugin for CloudFlare Turnstile.
306
311
  - [`fastify-cloudinary`](https://github.com/Vanilla-IceCream/fastify-cloudinary)
307
- The Cloudinary Fastify SDK allows you to quickly and easily integrate your
308
- application with Cloudinary. Effortlessly optimize and transform your cloud's
309
- assets.
312
+ Plugin to share a common Cloudinary connection across Fastify.
310
313
  - [`fastify-cockroachdb`](https://github.com/alex-ppg/fastify-cockroachdb)
311
314
  Fastify plugin to connect to a CockroachDB PostgreSQL instance via the
312
315
  Sequelize ORM.
@@ -416,6 +419,8 @@ section.
416
419
  Lightweight, proxy-aware redirect plugin from HTTP to HTTPS.
417
420
  - [`fastify-https-redirect`](https://github.com/tomsvogel/fastify-https-redirect)
418
421
  Fastify plugin for auto-redirect from HTTP to HTTPS.
422
+ - [`fastify-i18n`](https://github.com/Vanilla-IceCream/fastify-i18n)
423
+ Internationalization plugin for Fastify. Built upon node-polyglot.
419
424
  - [`fastify-impressions`](https://github.com/manju4ever/fastify-impressions)
420
425
  Fastify plugin to track impressions of all the routes.
421
426
  - [`fastify-influxdb`](https://github.com/alex-ppg/fastify-influxdb) Fastify
@@ -483,6 +488,9 @@ middlewares into Fastify plugins
483
488
  [mqtt](https://www.npmjs.com/package/mqtt) client across Fastify.
484
489
  - [`fastify-msgpack`](https://github.com/kenriortega/fastify-msgpack) Fastify
485
490
  and MessagePack, together at last. Uses @msgpack/msgpack by default.
491
+ - [`fastify-msgraph-webhook`](https://github.com/flower-of-the-bridges/fastify-msgraph-change-notifications-webhook)
492
+ to manage
493
+ [MS Graph Change Notifications webhooks](https://learn.microsoft.com/it-it/graph/change-notifications-delivery-webhooks?tabs=http).
486
494
  - [`fastify-multer`](https://github.com/fox1t/fastify-multer) Multer is a plugin
487
495
  for handling multipart/form-data, which is primarily used for uploading files.
488
496
  - [`fastify-nats`](https://github.com/mahmed8003/fastify-nats) Plugin to share
@@ -569,7 +577,7 @@ middlewares into Fastify plugins
569
577
  - [`fastify-rbac`](https://gitlab.com/m03geek/fastify-rbac) Fastify role-based
570
578
  access control plugin.
571
579
  - [`fastify-recaptcha`](https://github.com/qwertyforce/fastify-recaptcha)
572
- Fastify plugin for recaptcha verification.
580
+ Fastify plugin for reCAPTCHA verification.
573
581
  - [`fastify-redis-channels`](https://github.com/hearit-io/fastify-redis-channels)
574
582
  A plugin for fast, reliable, and scalable channels implementation based on
575
583
  Redis streams.
@@ -602,7 +610,7 @@ middlewares into Fastify plugins
602
610
  - [`fastify-sentry`](https://github.com/alex-ppg/fastify-sentry) Fastify plugin
603
611
  to add the Sentry SDK error handler to requests.
604
612
  - [`fastify-sequelize`](https://github.com/lyquocnam/fastify-sequelize) Fastify
605
- plugin work with Sequelize (adapter for NodeJS -> Sqlite, Mysql, Mssql,
613
+ plugin work with Sequelize (adapter for Node.js -> Sqlite, Mysql, Mssql,
606
614
  Postgres).
607
615
  - [`fastify-server-session`](https://github.com/jsumners/fastify-server-session)
608
616
  A session plugin with support for arbitrary backing caches via
@@ -682,10 +690,8 @@ middlewares into Fastify plugins
682
690
  [uws](https://github.com/uNetworking/uWebSockets).
683
691
  - [`fastify-xml-body-parser`](https://github.com/NaturalIntelligence/fastify-xml-body-parser)
684
692
  Parse XML payload / request body into JS / JSON object.
685
- - [`fastify-xray`](https://github.com/jeromemacias/fastify-xray) Fastify plugin
686
- for AWS XRay recording.
687
693
  - [`http-wizard`](https://github.com/flodlc/http-wizard)
688
- Exports a typescript api client for your Fastify api and ensures fullstack type
694
+ Exports a typescript API client for your Fastify API and ensures fullstack type
689
695
  safety for your project.
690
696
  - [`i18next-http-middleware`](https://github.com/i18next/i18next-http-middleware#fastify-usage)
691
697
  An [i18next](https://www.i18next.com) based i18n (internationalization)
@@ -722,3 +728,7 @@ middlewares into Fastify plugins
722
728
  Fastify APIs using decorators and convert Typescript interface to JSON Schema.
723
729
  - [`simple-tjscli`](https://github.com/imjuni/simple-tjscli) CLI tool to
724
730
  generate JSON Schema from TypeScript interfaces.
731
+ - [`vite-plugin-fastify`](https://github.com/Vanilla-IceCream/vite-plugin-fastify)
732
+ Fastify plugin for Vite with Hot-module Replacement.
733
+ - [`vite-plugin-fastify-routes`](https://github.com/Vanilla-IceCream/vite-plugin-fastify-routes)
734
+ File-based routing for Fastify applications using Vite.
@@ -32,6 +32,7 @@ Let's write our first server:
32
32
 
33
33
  // ESM
34
34
  import Fastify from 'fastify'
35
+
35
36
  const fastify = Fastify({
36
37
  logger: true
37
38
  })
@@ -68,6 +69,7 @@ Do you prefer to use `async/await`? Fastify supports it out-of-the-box.
68
69
  ```js
69
70
  // ESM
70
71
  import Fastify from 'fastify'
72
+
71
73
  const fastify = Fastify({
72
74
  logger: true
73
75
  })
@@ -353,7 +353,7 @@ This variant becomes extremely useful if you plan to distribute your plugin, as
353
353
  described in the next section.
354
354
 
355
355
  As you probably noticed by now, `request` and `reply` are not the standard
356
- Nodejs *request* and *response* objects, but Fastify's objects.
356
+ Node.js *request* and *response* objects, but Fastify's objects.
357
357
 
358
358
 
359
359
  ## How to handle encapsulation and distribution
@@ -43,7 +43,7 @@ defect a validation library can have.
43
43
  To understand this, we need to understand how JavaScript works a bit.
44
44
  Every object in JavaScript can have a prototype. It is a set of methods and
45
45
  properties it "inherits" from another object. I have put inherits in quotes
46
- because JavaScript isn't really an object-oriented language.It is prototype-
46
+ because JavaScript isn't really an object-oriented language. It is a prototype-
47
47
  based object-oriented language.
48
48
 
49
49
  A long time ago, for a bunch of irrelevant reasons, someone decided that it
@@ -314,8 +314,7 @@ Below is a table with all the error codes that Fastify uses.
314
314
  | <a id="fst_err_log_invalid_destination">FST_ERR_LOG_INVALID_DESTINATION</a> | The logger does not accept the specified destination. | Use a `'stream'` or a `'file'` as the destination. | [#1168](https://github.com/fastify/fastify/pull/1168) |
315
315
  | <a id="fst_err_log_invalid_logger">FST_ERR_LOG_INVALID_LOGGER</a> | The logger should have all these methods: `'info'`, `'error'`, `'debug'`, `'fatal'`, `'warn'`, `'trace'`, `'child'`. | Use a logger with all the required methods. | [#4520](https://github.com/fastify/fastify/pull/4520) |
316
316
  | <a id="fst_err_rep_invalid_payload_type">FST_ERR_REP_INVALID_PAYLOAD_TYPE</a> | Reply payload can be either a `string` or a `Buffer`. | Use a `string` or a `Buffer` for the payload. | [#1168](https://github.com/fastify/fastify/pull/1168) |
317
- | <a id="fst_err_rep_response_body_consumed">FST_ERR_REP_RESPONSE_BODY_CONSUMED</a> | Using `Response` as reply payload
318
- but the body is being consumed. | Make sure you don't consume the `Response.body` | [#5286](https://github.com/fastify/fastify/pull/5286) |
317
+ | <a id="fst_err_rep_response_body_consumed">FST_ERR_REP_RESPONSE_BODY_CONSUMED</a> | Using `Response` as reply payload, but the body is being consumed. | Make sure you don't consume the `Response.body` | [#5286](https://github.com/fastify/fastify/pull/5286) |
319
318
  | <a id="fst_err_rep_already_sent">FST_ERR_REP_ALREADY_SENT</a> | A response was already sent. | - | [#1336](https://github.com/fastify/fastify/pull/1336) |
320
319
  | <a id="fst_err_rep_sent_value">FST_ERR_REP_SENT_VALUE</a> | The only possible value for `reply.sent` is `true`. | - | [#1336](https://github.com/fastify/fastify/pull/1336) |
321
320
  | <a id="fst_err_send_inside_onerr">FST_ERR_SEND_INSIDE_ONERR</a> | You cannot use `send` inside the `onError` hook. | - | [#1348](https://github.com/fastify/fastify/pull/1348) |
@@ -338,7 +337,7 @@ but the body is being consumed. | Make sure you don't consume the `Response.body
338
337
  | <a id="fst_err_init_opts_invalid">FST_ERR_INIT_OPTS_INVALID</a> | Invalid initialization options. | Use valid initialization options. | [#1471](https://github.com/fastify/fastify/pull/1471) |
339
338
  | <a id="fst_err_force_close_connections_idle_not_available">FST_ERR_FORCE_CLOSE_CONNECTIONS_IDLE_NOT_AVAILABLE</a> | Cannot set forceCloseConnections to `idle` as your HTTP server does not support `closeIdleConnections` method. | Use a different value for `forceCloseConnections`. | [#3925](https://github.com/fastify/fastify/pull/3925) |
340
339
  | <a id="fst_err_duplicated_route">FST_ERR_DUPLICATED_ROUTE</a> | The HTTP method already has a registered controller for that URL. | Use a different URL or register the controller for another HTTP method. | [#2954](https://github.com/fastify/fastify/pull/2954) |
341
- | <a id="fst_err_bad_url">FST_ERR_BAD_URL</a> | The router received an invalid url. | Use a valid URL. | [#2106](https://github.com/fastify/fastify/pull/2106) |
340
+ | <a id="fst_err_bad_url">FST_ERR_BAD_URL</a> | The router received an invalid URL. | Use a valid URL. | [#2106](https://github.com/fastify/fastify/pull/2106) |
342
341
  | <a id="fst_err_async_constraint">FST_ERR_ASYNC_CONSTRAINT</a> | The router received an error when using asynchronous constraints. | - | [#4323](https://github.com/fastify/fastify/pull/4323) |
343
342
  | <a id="fst_err_default_route_invalid_type">FST_ERR_DEFAULT_ROUTE_INVALID_TYPE</a> | The `defaultRoute` type should be a function. | Use a function for the `defaultRoute`. | [#2733](https://github.com/fastify/fastify/pull/2733) |
344
343
  | <a id="fst_err_invalid_url">FST_ERR_INVALID_URL</a> | URL must be a string. | Use a string for the URL. | [#3653](https://github.com/fastify/fastify/pull/3653) |
@@ -189,9 +189,11 @@ specific header in case of error.
189
189
  It is not intended for changing the error, and calling `reply.send` will throw
190
190
  an exception.
191
191
 
192
- This hook will be executed only after the `customErrorHandler` has been
193
- executed, and only if the `customErrorHandler` sends an error back to the user
194
- *(Note that the default `customErrorHandler` always sends the error back to the
192
+ This hook will be executed only after
193
+ the [Custom Error Handler set by `setErrorHandler`](./Server.md#seterrorhandler)
194
+ has been executed, and only if the custom error handler sends an error back to the
195
+ user
196
+ *(Note that the default error handler always sends the error back to the
195
197
  user)*.
196
198
 
197
199
  **Notice:** unlike the other hooks, passing an error to the `done` function is not
@@ -1,7 +1,8 @@
1
1
  <h1 align="center">Fastify</h1>
2
2
 
3
3
  ## Long Term Support
4
- <a id="lts"></a>
4
+
5
+ `<a id="lts"></a>`
5
6
 
6
7
  Fastify's Long Term Support (LTS) is provided according to the schedule laid out
7
8
  in this document:
@@ -10,18 +11,27 @@ in this document:
10
11
  versions, are supported for a minimum period of six months from their release
11
12
  date. The release date of any specific version can be found at
12
13
  [https://github.com/fastify/fastify/releases](https://github.com/fastify/fastify/releases).
13
-
14
14
  2. Major releases will receive security updates for an additional six months
15
15
  from the release of the next major release. After this period we will still
16
16
  review and release security fixes as long as they are provided by the
17
17
  community and they do not violate other constraints, e.g. minimum supported
18
18
  Node.js version.
19
-
20
19
  3. Major releases will be tested and verified against all Node.js release lines
21
20
  that are supported by the [Node.js LTS
22
21
  policy](https://github.com/nodejs/Release) within the LTS period of that
23
22
  given Fastify release line. This implies that only the latest Node.js release
24
23
  of a given line is supported.
24
+ 4. In addition to Node.js runtime, major releases of Fastify will also be tested
25
+ and verified against alternative runtimes that are compatible with Node.js.
26
+ The maintenance teams of these alternative runtimes are responsible for ensuring
27
+ and guaranteeing these tests work properly.
28
+ 1. [N|Solid](https://docs.nodesource.com/nsolid), maintained by NodeSource,
29
+ commits to testing and verifying each Fastify major release against the N|Solid
30
+ LTS versions that are current at the time of the Fastify release.
31
+ NodeSource guarantees that Fastify will be compatible and function correctly
32
+ with N|Solid, aligning with the support and compatibility scope of the N|Solid
33
+ LTS versions available at the time of the Fastify release.
34
+ This ensures users of N|Solid can confidently use Fastify.
25
35
 
26
36
  A "month" is defined as 30 consecutive days.
27
37
 
@@ -38,33 +48,35 @@ A "month" is defined as 30 consecutive days.
38
48
  > dependency as `"fastify": "~3.15.x"`. This will leave your application
39
49
  > vulnerable, so please use with caution.
40
50
 
41
- [semver]: https://semver.org/
42
-
43
51
  ### Schedule
44
- <a id="lts-schedule"></a>
45
52
 
46
- | Version | Release Date | End Of LTS Date | Node.js |
47
- | :------ | :----------- | :-------------- | :------------------- |
48
- | 1.0.0 | 2018-03-06 | 2019-09-01 | 6, 8, 9, 10, 11 |
49
- | 2.0.0 | 2019-02-25 | 2021-01-31 | 6, 8, 10, 12, 14 |
50
- | 3.0.0 | 2020-07-07 | 2023-06-30 | 10, 12, 14, 16, 18 |
51
- | 4.0.0 | 2022-06-08 | TBD | 14, 16, 18, 20 |
53
+ `<a id="lts-schedule"></a>`
54
+
55
+ | Version | Release Date | End Of LTS Date | Node.js | Nsolid(Node) |
56
+ | :------ | :----------- | :-------------- | :----------------- | :------------- |
57
+ | 1.0.0 | 2018-03-06 | 2019-09-01 | 6, 8, 9, 10, 11 | |
58
+ | 2.0.0 | 2019-02-25 | 2021-01-31 | 6, 8, 10, 12, 14 | |
59
+ | 3.0.0 | 2020-07-07 | 2023-06-30 | 10, 12, 14, 16, 18 | v5(18) |
60
+ | 4.0.0 | 2022-06-08 | TBD | 14, 16, 18, 20 | v5(18), v5(20) |
52
61
 
53
62
  ### CI tested operating systems
54
- <a id="supported-os"></a>
55
63
 
56
- Fastify uses GitHub Actions for CI testing, please refer to [GitHub's
64
+ `<a id="supported-os"></a>`
65
+
66
+ Fastify uses GitHub Actions for CI testing, please refer to [GitHub&#39;s
57
67
  documentation regarding workflow
58
68
  runners](https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources)
59
69
  for further details on what the latest virtual environment is in relation to the
60
70
  YAML workflow labels below:
61
71
 
62
- | OS | YAML Workflow Label | Package Manager | Node.js |
63
- |---------|------------------------|---------------------------|--------------|
64
- | Linux | `ubuntu-latest` | npm | 14,16,18,20 |
65
- | Linux | `ubuntu-latest` | yarn,pnpm | 14,16,18,20 |
66
- | Windows | `windows-latest` | npm | 14,16,18,20 |
67
- | MacOS | `macos-latest` | npm | 14,16,18,20 |
72
+ | OS | YAML Workflow Label | Package Manager | Node.js | Nsolid(Node) |
73
+ | ------- | ------------------- | --------------- | ----------- | ------------- |
74
+ | Linux | `ubuntu-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
75
+ | Linux | `ubuntu-latest` | yarn,pnpm | 14,16,18,20 | v5(18),v5(20) |
76
+ | Windows | `windows-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
77
+ | MacOS | `macos-latest` | npm | 14,16,18,20 | v5(18),v5(20) |
68
78
 
69
79
  Using [yarn](https://yarnpkg.com/) might require passing the `--ignore-engines`
70
80
  flag.
81
+
82
+ [semver]: https://semver.org/
@@ -106,7 +106,7 @@ is generated. See Fastify Factory
106
106
  The default logger is configured with a set of standard serializers that
107
107
  serialize objects with `req`, `res`, and `err` properties. The object received
108
108
  by `req` is the Fastify [`Request`](./Request.md) object, while the object
109
- received by `res` is the Fastify [`Reply`](./Reply.md) object. This behaviour
109
+ received by `res` is the Fastify [`Reply`](./Reply.md) object. This behavior
110
110
  can be customized by specifying custom serializers.
111
111
 
112
112
  ```js
@@ -62,7 +62,7 @@ since the request was received by Fastify.
62
62
  - `.hasTrailer(key)` - Determine if a trailer has been set.
63
63
  - `.removeTrailer(key)` - Remove the value of a previously set trailer.
64
64
  - `.type(value)` - Sets the header `Content-Type`.
65
- - `.redirect([code,] dest)` - Redirect to the specified url, the status code is
65
+ - `.redirect([code,] dest)` - Redirect to the specified URL, the status code is
66
66
  optional (default to `302`).
67
67
  - `.callNotFound()` - Invokes the custom not found handler.
68
68
  - `.serialize(payload)` - Serializes the specified payload using the default
@@ -783,7 +783,7 @@ headers in one place. The payload provided inside `Response` is
783
783
  considered to be pre-serialized, so they will be sent unmodified
784
784
  without response validation.
785
785
 
786
- Plese be aware when using `Response`, the status code and headers
786
+ Please be aware when using `Response`, the status code and headers
787
787
  will not directly reflect to `reply.statusCode` and `reply.getHeaders()`.
788
788
  Such behavior is based on `Response` only allow `readonly` status
789
789
  code and headers. The data is not allow to be bi-direction editing,
@@ -842,7 +842,7 @@ To customize the JSON error output you can do it by:
842
842
  - add the additional properties to the `Error` instance
843
843
 
844
844
  Notice that if the returned status code is not in the response schema list, the
845
- default behaviour will be applied.
845
+ default behavior will be applied.
846
846
 
847
847
  ```js
848
848
  fastify.get('/', {
@@ -107,7 +107,7 @@ fastify.post('/:params', options, function (request, reply) {
107
107
  console.log(request.hostname)
108
108
  console.log(request.protocol)
109
109
  console.log(request.url)
110
- console.log(request.routerMethod)
110
+ console.log(request.routeOptions.method)
111
111
  console.log(request.routeOptions.bodyLimit)
112
112
  console.log(request.routeOptions.method)
113
113
  console.log(request.routeOptions.url)
@@ -116,7 +116,7 @@ fastify.post('/:params', options, function (request, reply) {
116
116
  console.log(request.routeOptions.version)
117
117
  console.log(request.routeOptions.exposeHeadRoute)
118
118
  console.log(request.routeOptions.prefixTrailingSlash)
119
- console.log(request.routerPath.logLevel)
119
+ console.log(request.routeOptions.logLevel)
120
120
  request.log.info('some info')
121
121
  })
122
122
  ```
@@ -34,7 +34,8 @@ fastify.route(options)
34
34
 
35
35
  * `method`: currently it supports `'DELETE'`, `'GET'`, `'HEAD'`, `'PATCH'`,
36
36
  `'POST'`, `'PUT'`, `'OPTIONS'`, `'SEARCH'`, `'TRACE'`, `'PROPFIND'`,
37
- `'PROPPATCH'`, `'MKCOL'`, `'COPY'`, `'MOVE'`, `'LOCK'` and `'UNLOCK'`.
37
+ `'PROPPATCH'`, `'MKCOL'`, `'COPY'`, `'MOVE'`, `'LOCK'`, `'UNLOCK'`,
38
+ `'REPORT'` and `'MKCALENDAR'`.
38
39
  It could also be an array of methods.
39
40
  * `url`: the path of the URL to match this route (alias: `path`).
40
41
  * `schema`: an object containing the schemas for the request and response. They
@@ -42,7 +43,7 @@ fastify.route(options)
42
43
  [here](./Validation-and-Serialization.md) for more info.
43
44
 
44
45
  * `body`: validates the body of the request if it is a POST, PUT, PATCH,
45
- TRACE, or SEARCH method.
46
+ TRACE, SEARCH, PROPFIND, PROPPATCH or LOCK method.
46
47
  * `querystring` or `query`: validates the querystring. This can be a complete
47
48
  JSON Schema object, with the property `type` of `object` and `properties`
48
49
  object of parameters, or simply the values of what would be contained in the
@@ -385,9 +385,15 @@ been sent. By setting this option to `true`, these log messages will be
385
385
  disabled. This allows for more flexible request start and end logging by
386
386
  attaching custom `onRequest` and `onResponse` hooks.
387
387
 
388
- Please note that this option will also disable an error log written by the
389
- default `onResponse` hook on reply callback errors. Other log messages
390
- emitted by Fastify will stay enabled, like deprecation warnings and messages
388
+ The other log entries that will be disabled are:
389
+ - an error log written by the default `onResponse` hook on reply callback errors
390
+ - the error and info logs written by the `defaultErrorHandler`
391
+ on error management
392
+ - the info log written by the `fourOhFour` handler when a
393
+ non existent route is requested
394
+
395
+ Other log messages emitted by Fastify will stay enabled,
396
+ like deprecation warnings and messages
391
397
  emitted when requests are received while the server is closing.
392
398
 
393
399
  ```js
@@ -572,7 +578,7 @@ const fastify = require('fastify')({
572
578
  comma separated values (e.g. `'127.0.0.1,192.168.1.1/24'`).
573
579
  + `Array<string>`: Trust only given IP/CIDR list (e.g. `['127.0.0.1']`).
574
580
  + `number`: Trust the nth hop from the front-facing proxy server as the client.
575
- + `Function`: Custom trust function that takes `address` as first arg
581
+ + `Function`: Custom trust function that takes `address` as first argument
576
582
  ```js
577
583
  function myTrustFn(address, hop) {
578
584
  return address === '1.2.3.4' || hop === 1
@@ -871,7 +877,7 @@ Fastify uses [find-my-way](https://github.com/delvedor/find-my-way) which suppor
871
877
  separating the path and query string with a `;` character (code 59), e.g. `/dev;foo=bar`.
872
878
  This decision originated from [delvedor/find-my-way#76]
873
879
  (https://github.com/delvedor/find-my-way/issues/76). Thus, this option will support
874
- backwards compatiblilty for the need to split on `;`. To disable support for splitting
880
+ backwards compatibility for the need to split on `;`. To disable support for splitting
875
881
  on `;` set `useSemicolonDelimiter` to `false`.
876
882
 
877
883
  ```js
@@ -17,10 +17,16 @@ convention, and there are several community ones available as well.
17
17
 
18
18
  The following inference packages are supported:
19
19
 
20
- - `json-schema-to-ts` -
21
- [github](https://github.com/ThomasAribart/json-schema-to-ts)
22
- - `typebox` - [github](https://github.com/sinclairzx81/typebox)
23
- - `zod` - [github](https://github.com/colinhacks/zod)
20
+ - [`json-schema-to-ts`](https://github.com/ThomasAribart/json-schema-to-ts)
21
+ - [`typebox`](https://github.com/sinclairzx81/typebox)
22
+ - [`zod`](https://github.com/colinhacks/zod)
23
+
24
+ See also the Type Provider wrapper packages for each of the packages respectively:
25
+
26
+ - [`@fastify/type-provider-json-schema-to-ts`](https://github.com/fastify/fastify-type-provider-json-schema-to-ts)
27
+ - [`@fastify/type-provider-typebox`](https://github.com/fastify/fastify-type-provider-typebox)
28
+ - [`fastify-type-provider-zod`](https://github.com/turkerdev/fastify-type-provider-zod)
29
+ (3rd party)
24
30
 
25
31
  ### Json Schema to Ts
26
32