fastify 4.5.2 → 4.5.3

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.
@@ -102,11 +102,15 @@ section.
102
102
  - [`@fastify/schedule`](https://github.com/fastify/fastify-schedule) Plugin for
103
103
  scheduling periodic jobs, based on
104
104
  [toad-scheduler](https://github.com/kibertoad/toad-scheduler).
105
+ - [`@fastify/secure-session`](https://github.com/fastify/fastify-secure-session)
106
+ Create a secure stateless cookie session for Fastify.
105
107
  - [`@fastify/sensible`](https://github.com/fastify/fastify-sensible) Defaults
106
108
  for Fastify that everyone can agree on. It adds some useful decorators such as
107
109
  HTTP errors and assertions, but also more request and reply methods.
108
110
  - [`@fastify/session`](https://github.com/fastify/session) a session plugin for
109
111
  Fastify.
112
+ - [`@fastify/soap-client`](https://github.com/fastify/fastify-soap-client) a SOAP
113
+ client plugin for Fastify.
110
114
  - [`@fastify/static`](https://github.com/fastify/fastify-static) Plugin for
111
115
  serving static files as fast as possible.
112
116
  - [`@fastify/swagger`](https://github.com/fastify/fastify-swagger) Plugin for
@@ -485,8 +489,6 @@ section.
485
489
  - [`fastify-schema-to-typescript`](https://github.com/thomasthiebaud/fastify-schema-to-typescript)
486
490
  Generate typescript types based on your JSON/YAML validation schemas so they
487
491
  are always in sync.
488
- - [`fastify-secure-session`](https://github.com/mcollina/fastify-secure-session)
489
- Create a secure stateless cookie session for Fastify.
490
492
  - [`fastify-sentry`](https://github.com/alex-ppg/fastify-sentry) Fastify plugin
491
493
  to add the Sentry SDK error handler to requests.
492
494
  - [`fastify-sequelize`](https://github.com/lyquocnam/fastify-sequelize) Fastify
@@ -497,8 +499,6 @@ section.
497
499
  `fastify-caching`.
498
500
  - [`fastify-slonik`](https://github.com/Unbuttun/fastify-slonik) Fastify Slonik
499
501
  plugin, with this you can use slonik in every part of your server.
500
- - [`fastify-soap-client`](https://github.com/fastify/fastify-soap-client) a SOAP
501
- client plugin for Fastify.
502
502
  - [`fastify-socket.io`](https://github.com/alemagio/fastify-socket.io) a
503
503
  Socket.io plugin for Fastify.
504
504
  - [`fastify-split-validator`](https://github.com/MetCoder95/fastify-split-validator)
package/fastify.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const VERSION = '4.5.2'
3
+ const VERSION = '4.5.3'
4
4
 
5
5
  const Avvio = require('avvio')
6
6
  const http = require('http')
package/lib/decorate.js CHANGED
@@ -19,7 +19,7 @@ const {
19
19
  const warning = require('./warnings')
20
20
 
21
21
  function decorate (instance, name, fn, dependencies) {
22
- if (instance.hasOwnProperty(name)) {
22
+ if (Object.prototype.hasOwnProperty.call(instance, name)) {
23
23
  throw new FST_ERR_DEC_ALREADY_PRESENT(name)
24
24
  }
25
25
 
@@ -37,7 +37,7 @@ function decorate (instance, name, fn, dependencies) {
37
37
 
38
38
  function decorateConstructor (konstructor, name, fn, dependencies) {
39
39
  const instance = konstructor.prototype
40
- if (instance.hasOwnProperty(name) || hasKey(konstructor, name)) {
40
+ if (Object.prototype.hasOwnProperty.call(instance, name) || hasKey(konstructor, name)) {
41
41
  throw new FST_ERR_DEC_ALREADY_PRESENT(name)
42
42
  }
43
43
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fastify",
3
- "version": "4.5.2",
3
+ "version": "4.5.3",
4
4
  "description": "Fast and low overhead web framework, for Node.js",
5
5
  "main": "fastify.js",
6
6
  "type": "commonjs",
@@ -177,7 +177,7 @@
177
177
  "abstract-logging": "^2.0.1",
178
178
  "avvio": "^8.1.3",
179
179
  "find-my-way": "^7.0.0",
180
- "light-my-request": "^5.0.0",
180
+ "light-my-request": "^5.5.1",
181
181
  "pino": "^8.0.0",
182
182
  "process-warning": "^2.0.0",
183
183
  "proxy-addr": "^2.0.7",
package/test/404s.test.js CHANGED
@@ -1945,7 +1945,7 @@ test('Send 404 when frameworkError calls reply.callNotFound', t => {
1945
1945
  t.end()
1946
1946
  })
1947
1947
 
1948
- test('hooks are applied to not found handlers', async ({ equal }) => {
1948
+ test('hooks are applied to not found handlers /1', async ({ equal }) => {
1949
1949
  const fastify = Fastify()
1950
1950
 
1951
1951
  // adding await here is fundamental for this test
@@ -423,6 +423,28 @@ test('promise was fulfilled with undefined', t => {
423
423
  })
424
424
  })
425
425
 
426
+ test('promise was fulfilled with undefined using inject', async (t) => {
427
+ const stream = split(JSON.parse)
428
+ const fastify = Fastify({
429
+ logger: {
430
+ stream,
431
+ level: 'error'
432
+ }
433
+ })
434
+
435
+ fastify.get('/', async (req, reply) => {
436
+ })
437
+
438
+ stream.once('data', line => {
439
+ t.fail('should not log an error')
440
+ })
441
+
442
+ const res = await fastify.inject('/')
443
+
444
+ t.equal(res.body, '')
445
+ t.equal(res.statusCode, 200)
446
+ })
447
+
426
448
  test('error is not logged because promise was fulfilled with undefined but response was sent before promise resolution', t => {
427
449
  t.plan(4)
428
450
 
@@ -642,7 +642,7 @@ test('should register empty values', t => {
642
642
 
643
643
  fastify.register((instance, opts, done) => {
644
644
  instance.decorate('test', null)
645
- t.ok(instance.hasOwnProperty('test'))
645
+ t.ok(Object.prototype.hasOwnProperty.call(instance, 'test'))
646
646
  done()
647
647
  })
648
648
 
@@ -138,7 +138,7 @@ test('decorate should recognize getter/setter objects', t => {
138
138
  this._a = val
139
139
  }
140
140
  })
141
- t.equal(one.hasOwnProperty('foo'), true)
141
+ t.equal(Object.prototype.hasOwnProperty.call(one, 'foo'), true)
142
142
  t.equal(one.foo, undefined)
143
143
  one.foo = 'a'
144
144
  t.equal(one.foo, 'a')
@@ -154,6 +154,6 @@ test('decorate should recognize getter/setter objects', t => {
154
154
  decorator.add.call(two, 'foo', {
155
155
  getter: () => 'a getter'
156
156
  })
157
- t.equal(two.hasOwnProperty('foo'), true)
157
+ t.equal(Object.prototype.hasOwnProperty.call(two, 'foo'), true)
158
158
  t.equal(two.foo, 'a getter')
159
159
  })
@@ -174,7 +174,7 @@ export interface FastifyInstance<
174
174
  route<
175
175
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
176
176
  ContextConfig = ContextConfigDefault,
177
- SchemaCompiler = FastifySchema,
177
+ SchemaCompiler extends FastifySchema = FastifySchema,
178
178
  >(opts: RouteOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider>): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
179
179
 
180
180
  get: RouteShorthandMethod<RawServer, RawRequest, RawReply, TypeProvider>;
package/types/route.d.ts CHANGED
@@ -24,7 +24,7 @@ export interface RouteShorthandOptions<
24
24
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
25
25
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
26
26
  ContextConfig = ContextConfigDefault,
27
- SchemaCompiler = FastifySchema,
27
+ SchemaCompiler extends FastifySchema = FastifySchema,
28
28
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
29
29
  Logger extends FastifyLoggerInstance = FastifyLoggerInstance
30
30
  > {
@@ -84,7 +84,7 @@ export interface RouteShorthandOptionsWithHandler<
84
84
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
85
85
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
86
86
  ContextConfig = ContextConfigDefault,
87
- SchemaCompiler = FastifySchema,
87
+ SchemaCompiler extends FastifySchema = FastifySchema,
88
88
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
89
89
  Logger extends FastifyLoggerInstance = FastifyLoggerInstance
90
90
  > extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> {
@@ -100,16 +100,16 @@ export interface RouteShorthandMethod<
100
100
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
101
101
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
102
102
  > {
103
- <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
103
+ <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
104
104
  path: string,
105
105
  opts: RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>,
106
106
  handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
107
107
  ): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
108
- <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
108
+ <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
109
109
  path: string,
110
110
  handler: RouteHandlerMethod<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
111
111
  ): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
112
- <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
112
+ <RouteGeneric extends RouteGenericInterface = RouteGenericInterface, ContextConfig = ContextConfigDefault, SchemaCompiler extends FastifySchema = FastifySchema, Logger extends FastifyLoggerInstance = FastifyLoggerInstance>(
113
113
  path: string,
114
114
  opts: RouteShorthandOptionsWithHandler<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger>
115
115
  ): FastifyInstance<RawServer, RawRequest, RawReply, Logger, TypeProvider>;
@@ -124,7 +124,7 @@ export interface RouteOptions<
124
124
  RawReply extends RawReplyDefaultExpression<RawServer> = RawReplyDefaultExpression<RawServer>,
125
125
  RouteGeneric extends RouteGenericInterface = RouteGenericInterface,
126
126
  ContextConfig = ContextConfigDefault,
127
- SchemaCompiler = FastifySchema,
127
+ SchemaCompiler extends FastifySchema = FastifySchema,
128
128
  TypeProvider extends FastifyTypeProvider = FastifyTypeProviderDefault,
129
129
  Logger extends FastifyLoggerInstance = FastifyLoggerInstance
130
130
  > extends RouteShorthandOptions<RawServer, RawRequest, RawReply, RouteGeneric, ContextConfig, SchemaCompiler, TypeProvider, Logger> {