fastify 5.3.3 → 5.4.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 (70) hide show
  1. package/README.md +2 -0
  2. package/build/build-validation.js +2 -1
  3. package/docs/Guides/Delay-Accepting-Requests.md +3 -3
  4. package/docs/Guides/Ecosystem.md +9 -5
  5. package/docs/Reference/ContentTypeParser.md +1 -1
  6. package/docs/Reference/Errors.md +2 -2
  7. package/docs/Reference/Hooks.md +14 -14
  8. package/docs/Reference/Logging.md +3 -3
  9. package/docs/Reference/Middleware.md +1 -1
  10. package/docs/Reference/Reply.md +8 -8
  11. package/docs/Reference/Request.md +1 -1
  12. package/docs/Reference/Routes.md +3 -3
  13. package/docs/Reference/Server.md +35 -21
  14. package/docs/Reference/Validation-and-Serialization.md +1 -1
  15. package/fastify.d.ts +2 -1
  16. package/fastify.js +14 -2
  17. package/lib/configValidator.js +1 -1
  18. package/lib/errors.js +6 -0
  19. package/lib/pluginOverride.js +3 -1
  20. package/lib/reply.js +7 -11
  21. package/lib/request.js +3 -10
  22. package/lib/symbols.js +1 -0
  23. package/lib/warnings.js +8 -0
  24. package/package.json +8 -4
  25. package/test/404s.test.js +226 -325
  26. package/test/allow-unsafe-regex.test.js +19 -48
  27. package/test/als.test.js +28 -40
  28. package/test/async-await.test.js +11 -2
  29. package/test/body-limit.test.js +41 -65
  30. package/test/build-certificate.js +1 -1
  31. package/test/custom-parser-async.test.js +17 -22
  32. package/test/decorator-namespace.test._js_ +3 -4
  33. package/test/diagnostics-channel/async-delay-request.test.js +7 -16
  34. package/test/diagnostics-channel/sync-delay-request.test.js +7 -16
  35. package/test/helper.js +1 -1
  36. package/test/hooks-async.test.js +248 -218
  37. package/test/hooks.test.js +910 -769
  38. package/test/http-methods/lock.test.js +31 -31
  39. package/test/http-methods/mkcol.test.js +5 -9
  40. package/test/http-methods/proppatch.test.js +23 -29
  41. package/test/http-methods/report.test.js +44 -69
  42. package/test/http-methods/search.test.js +67 -82
  43. package/test/http2/closing.test.js +38 -20
  44. package/test/http2/secure-with-fallback.test.js +28 -27
  45. package/test/https/https.test.js +56 -53
  46. package/test/internals/errors.test.js +1 -1
  47. package/test/internals/handle-request.test.js +49 -66
  48. package/test/issue-4959.test.js +12 -3
  49. package/test/listen.4.test.js +31 -43
  50. package/test/nullable-validation.test.js +33 -46
  51. package/test/output-validation.test.js +24 -26
  52. package/test/plugin.2.test.js +104 -86
  53. package/test/plugin.3.test.js +56 -35
  54. package/test/plugin.4.test.js +124 -119
  55. package/test/proto-poisoning.test.js +78 -97
  56. package/test/request-error.test.js +0 -46
  57. package/test/route-hooks.test.js +112 -92
  58. package/test/route-prefix.test.js +194 -133
  59. package/test/schema-serialization.test.js +177 -154
  60. package/test/schema-special-usage.test.js +165 -132
  61. package/test/schema-validation.test.js +242 -205
  62. package/test/set-error-handler.test.js +58 -1
  63. package/test/skip-reply-send.test.js +64 -69
  64. package/test/trust-proxy.test.js +32 -58
  65. package/test/types/fastify.test-d.ts +3 -0
  66. package/test/types/request.test-d.ts +1 -0
  67. package/test/url-rewriting.test.js +45 -62
  68. package/types/request.d.ts +1 -0
  69. package/.taprc +0 -7
  70. package/.vscode/settings.json +0 -22
package/lib/request.js CHANGED
@@ -188,19 +188,12 @@ Object.defineProperties(Request.prototype, {
188
188
  exposeHeadRoute: context.exposeHeadRoute,
189
189
  prefixTrailingSlash: context.prefixTrailingSlash,
190
190
  handler: context.handler,
191
+ config: context.config,
192
+ schema: context.schema,
191
193
  version
192
194
  }
193
195
 
194
- Object.defineProperties(options, {
195
- config: {
196
- get: () => context.config
197
- },
198
- schema: {
199
- get: () => context.schema
200
- }
201
- })
202
-
203
- return Object.freeze(options)
196
+ return options
204
197
  }
205
198
  },
206
199
  is404: {
package/lib/symbols.js CHANGED
@@ -56,6 +56,7 @@ const keys = {
56
56
  // This symbol is only meant to be used for fastify tests and should not be used for any other purpose
57
57
  kTestInternals: Symbol('fastify.testInternals'),
58
58
  kErrorHandler: Symbol('fastify.errorHandler'),
59
+ kErrorHandlerAlreadySet: Symbol('fastify.errorHandlerAlreadySet'),
59
60
  kChildLoggerFactory: Symbol('fastify.childLoggerFactory'),
60
61
  kHasBeenDecorated: Symbol('fastify.hasBeenDecorated'),
61
62
  kKeepAliveConnections: Symbol('fastify.keepAliveConnections'),
package/lib/warnings.js CHANGED
@@ -25,6 +25,13 @@ const FSTWRN003 = createWarning({
25
25
  unlimited: true
26
26
  })
27
27
 
28
+ const FSTWRN004 = createWarning({
29
+ name: 'FastifyWarning',
30
+ code: 'FSTWRN004',
31
+ message: 'It seems that you are overriding an errorHandler in the same scope, which can lead to subtle bugs.',
32
+ unlimited: true
33
+ })
34
+
28
35
  const FSTSEC001 = createWarning({
29
36
  name: 'FastifySecurity',
30
37
  code: 'FSTSEC001',
@@ -35,5 +42,6 @@ const FSTSEC001 = createWarning({
35
42
  module.exports = {
36
43
  FSTWRN001,
37
44
  FSTWRN003,
45
+ FSTWRN004,
38
46
  FSTSEC001
39
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify",
3
- "version": "5.3.3",
3
+ "version": "5.4.0",
4
4
  "description": "Fast and low overhead web framework, for Node.js",
5
5
  "main": "fastify.js",
6
6
  "type": "commonjs",
@@ -23,7 +23,7 @@
23
23
  "test:validator:integrity": "npm run build:validation && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/error-serializer.js && git diff --quiet --ignore-all-space --ignore-blank-lines --ignore-cr-at-eol lib/configValidator.js",
24
24
  "test:typescript": "tsc test/types/import.ts --target es2022 --moduleResolution node16 --module node16 --noEmit && tsd",
25
25
  "test:watch": "npm run unit -- --watch --coverage-report=none --reporter=terse",
26
- "unit": "borp --reporter=@jsumners/line-reporter --coverage --check-coverage",
26
+ "unit": "borp",
27
27
  "unit:report": "c8 --reporter html borp --reporter=@jsumners/line-reporter",
28
28
  "citgm": "borp --reporter=@jsumners/line-reporter --coverage --check-coverage --concurrency=1"
29
29
  },
@@ -141,6 +141,11 @@
141
141
  "name": "KaKa Ng",
142
142
  "email": "kaka@kakang.dev",
143
143
  "url": "https://github.com/climba03003"
144
+ },
145
+ {
146
+ "name": "Jean Michelet",
147
+ "email": "jean.antoine.michelet@gmail.com",
148
+ "url": "https://github.com/jean-michelet"
144
149
  }
145
150
  ],
146
151
  "license": "MIT",
@@ -185,13 +190,12 @@
185
190
  "joi": "^17.12.3",
186
191
  "json-schema-to-ts": "^3.0.1",
187
192
  "JSONStream": "^1.3.5",
188
- "markdownlint-cli2": "^0.17.1",
193
+ "markdownlint-cli2": "^0.18.1",
189
194
  "neostandard": "^0.12.0",
190
195
  "node-forge": "^1.3.1",
191
196
  "proxyquire": "^2.1.3",
192
197
  "simple-get": "^4.0.1",
193
198
  "split2": "^4.2.0",
194
- "tap": "^21.0.0",
195
199
  "tsd": "^0.32.0",
196
200
  "typescript": "~5.8.2",
197
201
  "undici": "^6.13.0",