fastify 4.26.0 → 4.26.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.
@@ -386,6 +386,8 @@ section.
386
386
  Providers.
387
387
  - [`fastify-guard`](https://github.com/hsynlms/fastify-guard) A Fastify plugin
388
388
  that protects endpoints by checking authenticated user roles and/or scopes.
389
+ - [`fastify-hana`](https://github.com/yoav0gal/fastify-hana) connects your
390
+ application to [`SAP-HANA`](https://help.sap.com/docs/SAP_HANA_CLIENT).
389
391
  - [`fastify-hashids`](https://github.com/andersonjoseph/fastify-hashids) A Fastify
390
392
  plugin to encode/decode IDs using [hashids](https://github.com/niieani/hashids.js).
391
393
  - [`fastify-hasura`](https://github.com/ManUtopiK/fastify-hasura) A Fastify
@@ -29,8 +29,21 @@
29
29
  ## Warnings
30
30
 
31
31
  ### Warnings In Fastify
32
- Warnings are enabled by default. They can be disabled by using any
33
- of the following methods:
32
+
33
+ Fastify utilizes Node.js's [warning event](https://nodejs.org/api/process.html#event-warning)
34
+ API to notify users of deprecated features and known coding mistakes. Fastify's
35
+ warnings are recognizable by the `FSTWRN` and `FSTDEP` prefixes on warning
36
+ code. When encountering such a warning, it is highly recommended that the
37
+ cause of the warning be determined through use of the
38
+ [`--trace-warnings`](https://nodejs.org/api/cli.html#--trace-warnings) and
39
+ [`--trace-deprecation`](https://nodejs.org/api/cli.html#--trace-deprecation)
40
+ flags. These will produce stack traces pointing out where the issue occurs
41
+ in the application's code. Issues opened about warnings without including
42
+ this information may be closed due to lack of information.
43
+
44
+ In addition to tracing, warnings can also be disabled. It is not recommended to
45
+ disable warnings as a matter of course, but if necessary, they can be disabled
46
+ by using any of the following methods:
34
47
 
35
48
  - setting the `NODE_NO_WARNINGS` environment variable to `1`
36
49
  - passing the `--no-warnings` flag to the node process
package/fastify.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const VERSION = '4.26.0'
3
+ const VERSION = '4.26.1'
4
4
 
5
5
  const Avvio = require('avvio')
6
6
  const http = require('node:http')
@@ -25,35 +25,34 @@
25
25
 
26
26
  if (obj === null) return '{}'
27
27
 
28
-
29
- let addComma = false
30
- let json = '{'
31
-
32
- if (obj["statusCode"] !== undefined) {
33
- !addComma && (addComma = true) || (json += ',')
34
- json += "\"statusCode\":"
35
- json += serializer.asNumber(obj["statusCode"])
36
- }
37
-
38
- if (obj["code"] !== undefined) {
39
- !addComma && (addComma = true) || (json += ',')
40
- json += "\"code\":"
41
- json += serializer.asString(obj["code"])
42
- }
43
-
44
- if (obj["error"] !== undefined) {
45
- !addComma && (addComma = true) || (json += ',')
46
- json += "\"error\":"
47
- json += serializer.asString(obj["error"])
48
- }
49
-
50
- if (obj["message"] !== undefined) {
51
- !addComma && (addComma = true) || (json += ',')
52
- json += "\"message\":"
53
- json += serializer.asString(obj["message"])
54
- }
55
-
56
- return json + '}'
28
+ let json = '{'
29
+ let addComma = false
30
+
31
+ if (obj["statusCode"] !== undefined) {
32
+ !addComma && (addComma = true) || (json += ',')
33
+ json += "\"statusCode\":"
34
+ json += serializer.asNumber(obj["statusCode"])
35
+ }
36
+
37
+ if (obj["code"] !== undefined) {
38
+ !addComma && (addComma = true) || (json += ',')
39
+ json += "\"code\":"
40
+ json += serializer.asString(obj["code"])
41
+ }
42
+
43
+ if (obj["error"] !== undefined) {
44
+ !addComma && (addComma = true) || (json += ',')
45
+ json += "\"error\":"
46
+ json += serializer.asString(obj["error"])
47
+ }
48
+
49
+ if (obj["message"] !== undefined) {
50
+ !addComma && (addComma = true) || (json += ',')
51
+ json += "\"message\":"
52
+ json += serializer.asString(obj["message"])
53
+ }
54
+
55
+ return json + '}'
57
56
 
58
57
  }
59
58
 
package/lib/errors.js CHANGED
@@ -464,5 +464,6 @@ module.exports.AVVIO_ERRORS_MAP = {
464
464
  AVV_ERR_PLUGIN_NOT_VALID: codes.FST_ERR_PLUGIN_NOT_VALID,
465
465
  AVV_ERR_ROOT_PLG_BOOTED: codes.FST_ERR_ROOT_PLG_BOOTED,
466
466
  AVV_ERR_PARENT_PLG_LOADED: codes.FST_ERR_PARENT_PLUGIN_BOOTED,
467
- AVV_ERR_READY_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT
467
+ AVV_ERR_READY_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT,
468
+ AVV_ERR_PLUGIN_EXEC_TIMEOUT: codes.FST_ERR_PLUGIN_TIMEOUT
468
469
  }
package/lib/warnings.js CHANGED
@@ -79,7 +79,7 @@ const FSTDEP019 = createDeprecation({
79
79
 
80
80
  const FSTDEP020 = createDeprecation({
81
81
  code: 'FSTDEP020',
82
- message: 'You are using the deprecated "reply.getResponseTime()"" method. Use the "request.elapsedTime" property instead. Method "reply.getResponseTime()" will be removed in `fastify@5`.'
82
+ message: 'You are using the deprecated "reply.getResponseTime()" method. Use the "reply.elapsedTime" property instead. Method "reply.getResponseTime()" will be removed in `fastify@5`.'
83
83
  })
84
84
 
85
85
  const FSTWRN001 = createWarning({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify",
3
- "version": "4.26.0",
3
+ "version": "4.26.1",
4
4
  "description": "Fast and low overhead web framework, for Node.js",
5
5
  "main": "fastify.js",
6
6
  "type": "commonjs",
@@ -204,7 +204,7 @@
204
204
  "@fastify/error": "^3.4.0",
205
205
  "@fastify/fast-json-stringify-compiler": "^4.3.0",
206
206
  "abstract-logging": "^2.0.1",
207
- "avvio": "^8.2.1",
207
+ "avvio": "^8.3.0",
208
208
  "fast-content-type-parse": "^1.1.0",
209
209
  "fast-json-stringify": "^5.8.0",
210
210
  "find-my-way": "^8.0.0",
@@ -295,7 +295,7 @@ t.test('onReady cannot add lifecycle hooks', t => {
295
295
  t.ok(error)
296
296
  t.equal(error.message, 'Root plugin has already booted')
297
297
  // TODO: look where the error pops up
298
- t.equal(error.code, 'AVV_ERR_PLUGIN_NOT_VALID')
298
+ t.equal(error.code, 'AVV_ERR_ROOT_PLG_BOOTED')
299
299
  done(error)
300
300
  }
301
301
  })
@@ -22,7 +22,7 @@ test('pluginTimeout', t => {
22
22
  "fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // to no call done on purpose'. You may have forgotten to call 'done' function or to resolve a Promise")
23
23
  t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
24
24
  t.ok(err.cause)
25
- t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
25
+ t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
26
26
  })
27
27
  })
28
28
 
@@ -40,7 +40,7 @@ test('pluginTimeout - named function', t => {
40
40
  "fastify-plugin: Plugin did not start in time: 'nameFunction'. You may have forgotten to call 'done' function or to resolve a Promise")
41
41
  t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
42
42
  t.ok(err.cause)
43
- t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
43
+ t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
44
44
  })
45
45
  })
46
46
 
@@ -60,7 +60,7 @@ test('pluginTimeout default', t => {
60
60
  "fastify-plugin: Plugin did not start in time: 'function (app, opts, done) { -- // default time elapsed without calling done'. You may have forgotten to call 'done' function or to resolve a Promise")
61
61
  t.equal(err.code, 'FST_ERR_PLUGIN_TIMEOUT')
62
62
  t.ok(err.cause)
63
- t.equal(err.cause.code, 'AVV_ERR_READY_TIMEOUT')
63
+ t.equal(err.cause.code, 'AVV_ERR_PLUGIN_EXEC_TIMEOUT')
64
64
  })
65
65
 
66
66
  t.teardown(clock.uninstall)
@@ -220,7 +220,7 @@ test('pretty print - empty plugins', t => {
220
220
  fastify.ready(() => {
221
221
  const tree = fastify.printPlugins()
222
222
  t.equal(typeof tree, 'string')
223
- t.match(tree, 'bound root')
223
+ t.match(tree, /root \d+ ms\n└── bound _after \d+ ms/m)
224
224
  })
225
225
  })
226
226
 
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,4 +1,3 @@
1
- import pino from 'pino'
2
1
  import { expectAssignable, expectType } from 'tsd'
3
2
  import fastify, {
4
3
  ContextConfigDefault,
@@ -83,6 +82,7 @@ const getHandler: RouteHandler = function (request, _reply) {
83
82
  expectType<FastifySchema>(request.routeSchema)
84
83
  expectType<FastifySchema>(request.routeOptions.schema)
85
84
  expectType<RouteHandlerMethod>(request.routeOptions.handler)
85
+ expectType<string | undefined>(request.routeOptions.url)
86
86
 
87
87
  expectType<RequestHeadersDefault & RawRequestDefaultExpression['headers']>(request.headers)
88
88
  request.headers = {}
@@ -22,10 +22,11 @@ export interface ValidationFunction {
22
22
 
23
23
  export interface RequestRouteOptions<ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema> {
24
24
  method: string;
25
- url: string;
26
- bodyLimit:number;
27
- attachValidation:boolean;
28
- logLevel:string;
25
+ // `url` can be `undefined` for instance when `request.is404` is true
26
+ url: string | undefined;
27
+ bodyLimit: number;
28
+ attachValidation: boolean;
29
+ logLevel: string;
29
30
  version: string | undefined;
30
31
  exposeHeadRoute: boolean;
31
32
  prefixTrailingSlash: string;
@@ -1,22 +0,0 @@
1
- {
2
- "workbench.colorCustomizations": {
3
- "[GitHub Dark]": {
4
- "tab.activeBackground": "#0d0d0d",
5
- "tab.activeBorder": "#ffff00"
6
- },
7
- "activityBar.background": "#BEE077",
8
- "activityBar.foreground": "#1C6B58",
9
- "activityBar.inactiveForeground": "#444444",
10
- "activityBar.activeBorder": "#411f88",
11
- "activityBar.activeBackground": "#2F9980",
12
- "activityBar.border": "#2F9980",
13
- "titleBar.activeBackground": "#A6D83D",
14
- "titleBar.activeForeground": "#1C6B58",
15
- "titleBar.inactiveBackground": "#9cbb5a",
16
- "titleBar.inactiveForeground": "#444444",
17
- "titleBar.border": "#2F9980",
18
- "statusBar.background": "#98C538",
19
- "statusBar.foreground": "#1C6B58",
20
- "statusBar.border": "#2F9980"
21
- }
22
- }