Socket
Socket
Sign inDemoInstall

fastify

Package Overview
Dependencies
63
Maintainers
3
Versions
282
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.14.0 to 4.14.1

test/internals/context.test.js

2

docs/Reference/Hooks.md

@@ -287,3 +287,3 @@ <h1 align="center">Fastify</h1>

The `onRequestAbort` hook is executed when a client closes the connection before
the entire request has been received. Therefore, you will not be able to send
the entire request has been processed. Therefore, you will not be able to send
data to the client.

@@ -290,0 +290,0 @@

@@ -741,3 +741,4 @@ <h1 align="center">Fastify</h1>

*Note: Only `FST_ERR_BAD_URL` is implemented at the moment.*
*Note: Only `FST_ERR_BAD_URL` and `FST_ERR_ASYNC_CONSTRAINT` are implemented at
the moment.*

@@ -744,0 +745,0 @@ ```js

'use strict'
const VERSION = '4.14.0'
const VERSION = '4.14.1'

@@ -5,0 +5,0 @@ const Avvio = require('avvio')

@@ -14,4 +14,4 @@ 'use strict'

kRouteByFastify,
kRequestValidateWeakMap,
kReplySerializeWeakMap,
kRequestCacheValidateFns,
kReplyCacheSerializeFns,
kPublicRouteContext

@@ -72,4 +72,4 @@ } = require('./symbols.js')

this[kRequestValidateWeakMap] = null
this[kReplySerializeWeakMap] = null
this[kRequestCacheValidateFns] = null
this[kReplyCacheSerializeFns] = null
this.validatorCompiler = validatorCompiler || null

@@ -76,0 +76,0 @@ this.serializerCompiler = serializerCompiler || null

@@ -21,3 +21,3 @@ 'use strict'

kSchemaResponse,
kReplySerializeWeakMap,
kReplyCacheSerializeFns,
kSchemaController,

@@ -327,3 +327,3 @@ kOptions,

} else if (typeof schemaOrStatus === 'object') {
serialize = this[kRouteContext][kReplySerializeWeakMap]?.get(schemaOrStatus)
serialize = this[kRouteContext][kReplyCacheSerializeFns]?.get(schemaOrStatus)
}

@@ -339,4 +339,4 @@

// Check if serialize function already compiled
if (this[kRouteContext][kReplySerializeWeakMap]?.has(schema)) {
return this[kRouteContext][kReplySerializeWeakMap].get(schema)
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
return this[kRouteContext][kReplyCacheSerializeFns].get(schema)
}

@@ -366,7 +366,7 @@

// encapsulated contexts
if (this[kRouteContext][kReplySerializeWeakMap] == null) {
this[kRouteContext][kReplySerializeWeakMap] = new WeakMap()
if (this[kRouteContext][kReplyCacheSerializeFns] == null) {
this[kRouteContext][kReplyCacheSerializeFns] = new WeakMap()
}
this[kRouteContext][kReplySerializeWeakMap].set(schema, serializeFn)
this[kRouteContext][kReplyCacheSerializeFns].set(schema, serializeFn)

@@ -400,4 +400,4 @@ return serializeFn

// Check if serialize function already compiled
if (this[kRouteContext][kReplySerializeWeakMap]?.has(schema)) {
serialize = this[kRouteContext][kReplySerializeWeakMap].get(schema)
if (this[kRouteContext][kReplyCacheSerializeFns]?.has(schema)) {
serialize = this[kRouteContext][kReplyCacheSerializeFns].get(schema)
} else {

@@ -404,0 +404,0 @@ serialize = this.compileSerializationSchema(schema, httpStatus, contentType)

@@ -14,3 +14,3 @@ 'use strict'

kOptions,
kRequestValidateWeakMap,
kRequestCacheValidateFns,
kRouteContext,

@@ -258,3 +258,3 @@ kPublicRouteContext

} else if (typeof httpPartOrSchema === 'object') {
return this[kRouteContext][kRequestValidateWeakMap]?.get(httpPartOrSchema)
return this[kRouteContext][kRequestCacheValidateFns]?.get(httpPartOrSchema)
}

@@ -267,4 +267,4 @@ }

if (this[kRouteContext][kRequestValidateWeakMap]?.has(schema)) {
return this[kRouteContext][kRequestValidateWeakMap].get(schema)
if (this[kRouteContext][kRequestCacheValidateFns]?.has(schema)) {
return this[kRouteContext][kRequestCacheValidateFns].get(schema)
}

@@ -293,7 +293,7 @@

// encapsulated contexts
if (this[kRouteContext][kRequestValidateWeakMap] == null) {
this[kRouteContext][kRequestValidateWeakMap] = new WeakMap()
if (this[kRouteContext][kRequestCacheValidateFns] == null) {
this[kRouteContext][kRequestCacheValidateFns] = new WeakMap()
}
this[kRouteContext][kRequestValidateWeakMap].set(schema, validateFn)
this[kRouteContext][kRequestCacheValidateFns].set(schema, validateFn)

@@ -324,4 +324,4 @@ return validateFn

if (validate == null) {
if (this[kRouteContext][kRequestValidateWeakMap]?.has(schema)) {
validate = this[kRouteContext][kRequestValidateWeakMap].get(schema)
if (this[kRouteContext][kRequestCacheValidateFns]?.has(schema)) {
validate = this[kRouteContext][kRequestCacheValidateFns].get(schema)
} else {

@@ -328,0 +328,0 @@ // We proceed to compile if there's no validate function yet

@@ -516,2 +516,3 @@ 'use strict'

}
reply[kReplyIsError] = true
}

@@ -518,0 +519,0 @@

@@ -30,6 +30,5 @@ 'use strict'

kRequest: Symbol('fastify.Request'),
kRequestValidateFns: Symbol('fastify.request.cache.validateFns'),
kRequestPayloadStream: Symbol('fastify.RequestPayloadStream'),
kRequestAcceptVersion: Symbol('fastify.RequestAcceptVersion'),
kRequestValidateWeakMap: Symbol('fastify.request.cache.validators'),
kRequestCacheValidateFns: Symbol('fastify.request.cache.validateFns'),
// 404

@@ -55,3 +54,3 @@ kFourOhFour: Symbol('fastify.404'),

kReplySerializerDefault: Symbol('fastify.replySerializerDefault'),
kReplySerializeWeakMap: Symbol('fastify.reply.cache.serializeFns'),
kReplyCacheSerializeFns: Symbol('fastify.reply.cache.serializeFns'),
// This symbol is only meant to be used for fastify tests and should not be used for any other purpose

@@ -58,0 +57,0 @@ kTestInternals: Symbol('fastify.testInternals'),

{
"name": "fastify",
"version": "4.14.0",
"version": "4.14.1",
"description": "Fast and low overhead web framework, for Node.js",

@@ -5,0 +5,0 @@ "main": "fastify.js",

'use strict'
const { test } = require('tap')
const { kReplySerializeWeakMap, kRouteContext } = require('../../lib/symbols')
const { kReplyCacheSerializeFns, kRouteContext } = require('../../lib/symbols')
const Fastify = require('../../fastify')

@@ -210,5 +210,5 @@

t.equal(reply[kRouteContext][kReplySerializeWeakMap], null)
t.equal(reply[kRouteContext][kReplyCacheSerializeFns], null)
t.equal(reply.compileSerializationSchema(getDefaultSchema())(input), JSON.stringify(input))
t.type(reply[kRouteContext][kReplySerializeWeakMap], WeakMap)
t.type(reply[kRouteContext][kReplyCacheSerializeFns], WeakMap)
t.equal(reply.compileSerializationSchema(getDefaultSchema())(input), JSON.stringify(input))

@@ -412,5 +412,5 @@

t.notOk(reply.getSerializationFunction(getDefaultSchema()))
t.equal(reply[kRouteContext][kReplySerializeWeakMap], null)
t.equal(reply[kRouteContext][kReplyCacheSerializeFns], null)
t.notOk(reply.getSerializationFunction('200'))
t.equal(reply[kRouteContext][kReplySerializeWeakMap], null)
t.equal(reply[kRouteContext][kReplyCacheSerializeFns], null)

@@ -689,5 +689,5 @@ reply.send({ hello: 'world' })

const input = { hello: 'world' }
t.equal(reply[kRouteContext][kReplySerializeWeakMap], null)
t.equal(reply[kRouteContext][kReplyCacheSerializeFns], null)
t.equal(reply.serializeInput(input, getDefaultSchema()), JSON.stringify(input))
t.type(reply[kRouteContext][kReplySerializeWeakMap], WeakMap)
t.type(reply[kRouteContext][kReplyCacheSerializeFns], WeakMap)

@@ -694,0 +694,0 @@ reply.send({ hello: 'world' })

@@ -35,3 +35,3 @@ 'use strict'

test('Once called, Reply should return an object with methods', t => {
t.plan(13)
t.plan(14)
const response = { res: 'res' }

@@ -54,2 +54,4 @@ const context = {}

t.equal(reply.request, request)
// Aim to not bad property keys (including Symbols)
t.notOk('undefined' in reply)
})

@@ -56,0 +58,0 @@

@@ -5,3 +5,3 @@ 'use strict'

const Ajv = require('ajv')
const { kRequestValidateWeakMap, kRouteContext } = require('../../lib/symbols')
const { kRequestCacheValidateFns, kRouteContext } = require('../../lib/symbols')
const Fastify = require('../../fastify')

@@ -235,7 +235,7 @@

fastify.get('/', (req, reply) => {
t.equal(req[kRouteContext][kRequestValidateWeakMap], null)
t.equal(req[kRouteContext][kRequestCacheValidateFns], null)
t.type(req.compileValidationSchema(defaultSchema), Function)
t.type(req[kRouteContext][kRequestValidateWeakMap], WeakMap)
t.type(req[kRouteContext][kRequestCacheValidateFns], WeakMap)
t.type(req.compileValidationSchema(Object.assign({}, defaultSchema)), Function)
t.type(req[kRouteContext][kRequestValidateWeakMap], WeakMap)
t.type(req[kRouteContext][kRequestCacheValidateFns], WeakMap)

@@ -429,3 +429,3 @@ reply.send({ hello: 'world' })

t.equal(req[kRouteContext][kRequestValidateWeakMap], null)
t.equal(req[kRouteContext][kRequestCacheValidateFns], null)
reply.send({ hello: 'world' })

@@ -730,5 +730,5 @@ })

fastify.get('/', (req, reply) => {
t.equal(req[kRouteContext][kRequestValidateWeakMap], null)
t.equal(req[kRouteContext][kRequestCacheValidateFns], null)
t.equal(req.validateInput({ hello: 'world' }, defaultSchema), true)
t.type(req[kRouteContext][kRequestValidateWeakMap], WeakMap)
t.type(req[kRouteContext][kRequestCacheValidateFns], WeakMap)

@@ -735,0 +735,0 @@ reply.send({ hello: 'world' })

@@ -69,2 +69,4 @@ 'use strict'

t.equal(request.routeSchema, context[kPublicRouteContext].schema)
// Aim to not bad property keys (including Symbols)
t.notOk('undefined' in request)

@@ -71,0 +73,0 @@ // This will be removed, it's deprecated

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc