fastify 3.23.1 → 3.25.1

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 (74) hide show
  1. package/README.md +30 -29
  2. package/build/sync-version.js +11 -0
  3. package/docs/{Benchmarking.md → Guides/Benchmarking.md} +14 -5
  4. package/docs/Guides/Ecosystem.md +513 -0
  5. package/docs/{Fluent-Schema.md → Guides/Fluent-Schema.md} +16 -7
  6. package/docs/{Getting-Started.md → Guides/Getting-Started.md} +191 -57
  7. package/docs/Guides/Index.md +30 -4
  8. package/docs/{Migration-Guide-V3.md → Guides/Migration-Guide-V3.md} +43 -37
  9. package/docs/{Plugins-Guide.md → Guides/Plugins-Guide.md} +196 -82
  10. package/docs/{Recommendations.md → Guides/Recommendations.md} +17 -10
  11. package/docs/{Serverless.md → Guides/Serverless.md} +200 -42
  12. package/docs/Guides/Style-Guide.md +246 -0
  13. package/docs/{Testing.md → Guides/Testing.md} +25 -11
  14. package/docs/Guides/Write-Plugin.md +102 -0
  15. package/docs/{ContentTypeParser.md → Reference/ContentTypeParser.md} +68 -30
  16. package/docs/{Decorators.md → Reference/Decorators.md} +52 -47
  17. package/docs/{Encapsulation.md → Reference/Encapsulation.md} +3 -3
  18. package/docs/{Errors.md → Reference/Errors.md} +77 -47
  19. package/docs/{HTTP2.md → Reference/HTTP2.md} +13 -13
  20. package/docs/{Hooks.md → Reference/Hooks.md} +157 -70
  21. package/docs/Reference/Index.md +71 -0
  22. package/docs/{LTS.md → Reference/LTS.md} +31 -32
  23. package/docs/{Lifecycle.md → Reference/Lifecycle.md} +15 -7
  24. package/docs/{Logging.md → Reference/Logging.md} +68 -28
  25. package/docs/Reference/Middleware.md +78 -0
  26. package/docs/{Plugins.md → Reference/Plugins.md} +91 -34
  27. package/docs/{Reply.md → Reference/Reply.md} +205 -94
  28. package/docs/{Request.md → Reference/Request.md} +32 -16
  29. package/docs/{Routes.md → Reference/Routes.md} +243 -111
  30. package/docs/{Server.md → Reference/Server.md} +516 -267
  31. package/docs/{TypeScript.md → Reference/TypeScript.md} +447 -187
  32. package/docs/{Validation-and-Serialization.md → Reference/Validation-and-Serialization.md} +178 -86
  33. package/docs/index.md +24 -0
  34. package/examples/typescript-server.ts +1 -1
  35. package/fastify.js +4 -24
  36. package/lib/decorate.js +6 -3
  37. package/lib/logger.js +1 -1
  38. package/lib/pluginUtils.js +1 -3
  39. package/lib/reply.js +4 -1
  40. package/lib/route.js +1 -1
  41. package/lib/server.js +9 -8
  42. package/lib/symbols.js +1 -0
  43. package/package.json +11 -5
  44. package/test/bundler/webpack/bundler-test.js +2 -6
  45. package/test/constrained-routes.test.js +220 -0
  46. package/test/custom-parser.test.js +11 -2
  47. package/test/decorator.test.js +38 -0
  48. package/test/handler-context.test.js +11 -4
  49. package/test/http2/closing.test.js +14 -5
  50. package/test/http2/constraint.test.js +91 -0
  51. package/test/internals/reply.test.js +42 -0
  52. package/test/internals/version.test.js +6 -34
  53. package/test/listen.test.js +36 -22
  54. package/test/logger.test.js +16 -0
  55. package/test/maxRequestsPerSocket.test.js +10 -0
  56. package/test/request-error.test.js +2 -8
  57. package/test/requestTimeout.test.js +4 -1
  58. package/test/route-hooks.test.js +55 -0
  59. package/test/router-options.test.js +10 -1
  60. package/test/schema-feature.test.js +146 -0
  61. package/test/stream.test.js +14 -3
  62. package/test/trust-proxy.test.js +15 -7
  63. package/test/types/instance.test-d.ts +52 -1
  64. package/test/types/request.test-d.ts +7 -1
  65. package/test/types/route.test-d.ts +21 -0
  66. package/types/hooks.d.ts +12 -1
  67. package/types/instance.d.ts +17 -7
  68. package/types/request.d.ts +4 -1
  69. package/types/route.d.ts +1 -1
  70. package/docs/Ecosystem.md +0 -211
  71. package/docs/Middleware.md +0 -53
  72. package/docs/Style-Guide.md +0 -185
  73. package/docs/Write-Plugin.md +0 -58
  74. package/out +0 -431
package/README.md CHANGED
@@ -146,7 +146,7 @@ fastify.listen(3000, (err, address) => {
146
146
  })
147
147
  ```
148
148
 
149
- Do you want to know more? Head to the <a href="./docs/Getting-Started.md"><code><b>Getting Started</b></code></a>.
149
+ Do you want to know more? Head to the <a href="./docs/Guides/Getting-Started.md"><code><b>Getting Started</b></code></a>.
150
150
 
151
151
 
152
152
  ### Fastify v1.x and v2.x
@@ -156,7 +156,7 @@ In a similar way, all Fastify **v2.x** related changes should be based on [**`br
156
156
 
157
157
  > ## Note
158
158
  > `.listen` binds to the local host, `localhost`, interface by default (`127.0.0.1` or `::1`, depending on the operating system configuration). If you are running Fastify in a container (Docker, [GCP](https://cloud.google.com/), etc.), you may need to bind to `0.0.0.0`. Be careful when deciding to listen on all interfaces; it comes with inherent [security risks](https://web.archive.org/web/20170711105010/https://snyk.io/blog/mongodb-hack-and-secure-defaults/).
159
- > See [the documentation](./docs/Server.md#listen) for more information.
159
+ > See [the documentation](./docs/Reference/Server.md#listen) for more information.
160
160
 
161
161
  ### Core features
162
162
 
@@ -189,39 +189,39 @@ depends on your application, you should __always__ benchmark if performance
189
189
  matters to you.
190
190
 
191
191
  ## Documentation
192
- * <a href="./docs/Getting-Started.md"><code><b>Getting Started</b></code></a>
192
+ * <a href="./docs/Guides/Getting-Started.md"><code><b>Getting Started</b></code></a>
193
193
  * <a href="./docs/Guides/Index.md"><code><b>Guides</b></code></a>
194
- * <a href="./docs/Server.md"><code><b>Server</b></code></a>
195
- * <a href="./docs/Routes.md"><code><b>Routes</b></code></a>
196
- * <a href="./docs/Encapsulation.md"><code><b>Encapsulation</b></code></a>
197
- * <a href="./docs/Logging.md"><code><b>Logging</b></code></a>
198
- * <a href="./docs/Middleware.md"><code><b>Middleware</b></code></a>
199
- * <a href="./docs/Hooks.md"><code><b>Hooks</b></code></a>
200
- * <a href="./docs/Decorators.md"><code><b>Decorators</b></code></a>
201
- * <a href="./docs/Validation-and-Serialization.md"><code><b>Validation and Serialization</b></code></a>
202
- * <a href="./docs/Fluent-Schema.md"><code><b>Fluent Schema</b></code></a>
203
- * <a href="./docs/Lifecycle.md"><code><b>Lifecycle</b></code></a>
204
- * <a href="./docs/Reply.md"><code><b>Reply</b></code></a>
205
- * <a href="./docs/Request.md"><code><b>Request</b></code></a>
206
- * <a href="./docs/Errors.md"><code><b>Errors</b></code></a>
207
- * <a href="./docs/ContentTypeParser.md"><code><b>Content Type Parser</b></code></a>
208
- * <a href="./docs/Plugins.md"><code><b>Plugins</b></code></a>
209
- * <a href="./docs/Testing.md"><code><b>Testing</b></code></a>
210
- * <a href="./docs/Benchmarking.md"><code><b>Benchmarking</b></code></a>
211
- * <a href="./docs/Write-Plugin.md"><code><b>How to write a good plugin</b></code></a>
212
- * <a href="./docs/Plugins-Guide.md"><code><b>Plugins Guide</b></code></a>
213
- * <a href="./docs/HTTP2.md"><code><b>HTTP2</b></code></a>
214
- * <a href="./docs/LTS.md"><code><b>Long Term Support</b></code></a>
215
- * <a href="./docs/TypeScript.md"><code><b>TypeScript and types support</b></code></a>
216
- * <a href="./docs/Serverless.md"><code><b>Serverless</b></code></a>
217
- * <a href="./docs/Recommendations.md"><code><b>Recommendations</b></code></a>
194
+ * <a href="./docs/Reference/Server.md"><code><b>Server</b></code></a>
195
+ * <a href="./docs/Reference/Routes.md"><code><b>Routes</b></code></a>
196
+ * <a href="./docs/Reference/Encapsulation.md"><code><b>Encapsulation</b></code></a>
197
+ * <a href="./docs/Reference/Logging.md"><code><b>Logging</b></code></a>
198
+ * <a href="./docs/Reference/Middleware.md"><code><b>Middleware</b></code></a>
199
+ * <a href="./docs/Reference/Hooks.md"><code><b>Hooks</b></code></a>
200
+ * <a href="./docs/Reference/Decorators.md"><code><b>Decorators</b></code></a>
201
+ * <a href="./docs/Reference/Validation-and-Serialization.md"><code><b>Validation and Serialization</b></code></a>
202
+ * <a href="./docs/Guides/Fluent-Schema.md"><code><b>Fluent Schema</b></code></a>
203
+ * <a href="./docs/Reference/Lifecycle.md"><code><b>Lifecycle</b></code></a>
204
+ * <a href="./docs/Reference/Reply.md"><code><b>Reply</b></code></a>
205
+ * <a href="./docs/Reference/Request.md"><code><b>Request</b></code></a>
206
+ * <a href="./docs/Reference/Errors.md"><code><b>Errors</b></code></a>
207
+ * <a href="./docs/Reference/ContentTypeParser.md"><code><b>Content Type Parser</b></code></a>
208
+ * <a href="./docs/Reference/Plugins.md"><code><b>Plugins</b></code></a>
209
+ * <a href="./docs/Guides/Testing.md"><code><b>Testing</b></code></a>
210
+ * <a href="./docs/Guides/Benchmarking.md"><code><b>Benchmarking</b></code></a>
211
+ * <a href="./docs/Guides/Write-Plugin.md"><code><b>How to write a good plugin</b></code></a>
212
+ * <a href="./docs/Guides/Plugins-Guide.md"><code><b>Plugins Guide</b></code></a>
213
+ * <a href="./docs/Reference/HTTP2.md"><code><b>HTTP2</b></code></a>
214
+ * <a href="./docs/Reference/LTS.md"><code><b>Long Term Support</b></code></a>
215
+ * <a href="./docs/Reference/TypeScript.md"><code><b>TypeScript and types support</b></code></a>
216
+ * <a href="./docs/Guides/Serverless.md"><code><b>Serverless</b></code></a>
217
+ * <a href="./docs/Guides/Recommendations.md"><code><b>Recommendations</b></code></a>
218
218
 
219
219
  中文文档[地址](https://github.com/fastify/docs-chinese/blob/HEAD/README.md)
220
220
 
221
221
  ## Ecosystem
222
222
 
223
- - [Core](./docs/Ecosystem.md#core) - Core plugins maintained by the _Fastify_ [team](#team).
224
- - [Community](./docs/Ecosystem.md#community) - Community supported plugins.
223
+ - [Core](./docs/Guides/Ecosystem.md#core) - Core plugins maintained by the _Fastify_ [team](#team).
224
+ - [Community](./docs/Guides/Ecosystem.md#community) - Community supported plugins.
225
225
  - [Live Examples](https://github.com/fastify/example) - Multirepo with a broad set of real working examples.
226
226
  - [Discord](https://discord.gg/D3FZYPy) - Join our discord server and chat with the maintainers.
227
227
 
@@ -251,6 +251,7 @@ Team members are listed in alphabetical order.
251
251
  * [__Rafael Gonzaga__](https://github.com/rafaelgss), <https://twitter.com/_rafaelgss>, <https://www.npmjs.com/~rafaelgss>
252
252
  * [__Vincent Le Goff__](https://github.com/zekth)
253
253
  * [__Luciano Mammino__](https://github.com/lmammino), <https://twitter.com/loige>, <https://www.npmjs.com/~lmammino>
254
+ * [__Luis Orbaiceta__](https://github.com/luisorbaiceta), <https://twitter.com/luisorbai>, <https://www.npmjs.com/~luisorbaiceta>
254
255
  * [__Maksim Sinik__](https://github.com/fox1t), <https://twitter.com/maksimsinik>, <https://www.npmjs.com/~fox1t>
255
256
  * [__Manuel Spigolon__](https://github.com/eomm), <https://twitter.com/manueomm>, <https://www.npmjs.com/~eomm>
256
257
  * [__James Sumners__](https://github.com/jsumners), <https://twitter.com/jsumners79>, <https://www.npmjs.com/~jsumners>
@@ -0,0 +1,11 @@
1
+ 'use strict'
2
+
3
+ const fs = require('fs')
4
+ const path = require('path')
5
+
6
+ // package.json:version -> fastify.js:VERSION
7
+ const { version } = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json')).toString('utf8'))
8
+
9
+ const fastifyJs = path.join(__dirname, '..', 'fastify.js')
10
+
11
+ fs.writeFileSync(fastifyJs, fs.readFileSync(fastifyJs).toString('utf8').replace(/const\s*VERSION\s*=.*/, `const VERSION = '${version}'`))
@@ -1,13 +1,22 @@
1
1
  <h1 align="center">Fastify</h1>
2
2
 
3
3
  ## Benchmarking
4
- Benchmarking is important if you want to measure how a change can affect the performance of your application. We provide a simple way to benchmark your application from the point of view of a user and contributor. The setup allows you to automate benchmarks in different branches and on different Node.js versions.
4
+ Benchmarking is important if you want to measure how a change can affect the
5
+ performance of your application. We provide a simple way to benchmark your
6
+ application from the point of view of a user and contributor. The setup allows
7
+ you to automate benchmarks in different branches and on different Node.js
8
+ versions.
5
9
 
6
10
  The modules we will use:
7
- - [Autocannon](https://github.com/mcollina/autocannon): A HTTP/1.1 benchmarking tool written in node.
8
- - [Branch-comparer](https://github.com/StarpTech/branch-comparer): Checkout multiple git branches, execute scripts and log the results.
9
- - [Concurrently](https://github.com/kimmobrunfeldt/concurrently): Run commands concurrently.
10
- - [Npx](https://github.com/npm/npx): NPM package runner used to run scripts against different Node.js Versions and to execute local binaries. Shipped with npm@5.2.0.
11
+ - [Autocannon](https://github.com/mcollina/autocannon): A HTTP/1.1 benchmarking
12
+ tool written in node.
13
+ - [Branch-comparer](https://github.com/StarpTech/branch-comparer): Checkout
14
+ multiple git branches, execute scripts and log the results.
15
+ - [Concurrently](https://github.com/kimmobrunfeldt/concurrently): Run commands
16
+ concurrently.
17
+ - [Npx](https://github.com/npm/npx): NPM package runner used to run scripts
18
+ against different Node.js Versions and to execute local binaries. Shipped with
19
+ npm@5.2.0.
11
20
 
12
21
  ## Simple
13
22