Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@architect/functions

Package Overview
Dependencies
Maintainers
6
Versions
284
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@architect/functions - npm Package Compare versions

Comparing version 5.3.4 to 5.4.0-RC.0

10

package.json
{
"name": "@architect/functions",
"version": "5.3.4",
"version": "5.4.0-RC.0",
"description": "Cloud function signatures for HTTP handlers, pub/sub + scheduled, queued functions, table triggers, and more",

@@ -40,3 +40,3 @@ "homepage": "https://github.com/architect/functions",

"@architect/req-res-fixtures": "git+https://github.com/architect/req-res-fixtures.git",
"@architect/sandbox": "^5.5.1",
"@architect/sandbox": "^5.5.2",
"@aws-sdk/client-apigatewaymanagementapi": "^3.213.0",

@@ -48,7 +48,7 @@ "@aws-sdk/client-dynamodb": "^3.213.0",

"@aws-sdk/lib-dynamodb": "^3.214.0",
"@types/aws-lambda": "^8.10.110",
"@types/node": "^18.13.0",
"@types/aws-lambda": "^8.10.111",
"@types/node": "^18.14.1",
"aws-sdk": "2.1055.0",
"cross-env": "~7.0.3",
"eslint": "^8.34.0",
"eslint": "^8.35.0",
"mock-fs": "~5.2.0",

@@ -55,0 +55,0 @@ "nyc": "~15.1.0",

let httpError = require('./errors')
let binaryTypes = require('./helpers/binary-types')
let { brotliCompressSync } = require('zlib')
let { brotliCompressSync: br, gzipSync: gzip } = require('zlib')
let compressionTypes = { br, gzip }

@@ -174,5 +175,5 @@ module.exports = function responseFormatter (req, params) {

let b64enc = i => new Buffer.from(i).toString('base64')
function compress (body) {
res.headers['content-encoding'] = 'br'
return brotliCompressSync(body)
function compress (body, type) {
res.headers['content-encoding'] = type
return compressionTypes[type](body)
}

@@ -182,4 +183,3 @@

// Legacy API Gateway (REST, i.e. !req.version) and ASAP (which sets isBase64Encoded) handle their own compression, so don't double-compress / encode
let shouldCompress = !encoding && acceptEncoding && acceptEncoding.includes('br') &&
req.version && !params.isBase64Encoded
let shouldCompress = req.version && !params.isBase64Encoded && !encoding && acceptEncoding && params.compression !== false
if (bodyIsBuffer) {

@@ -196,3 +196,11 @@ let body = shouldCompress ? compress(res.body) : res.body

else if (bodyIsString && shouldCompress) {
res.body = b64enc(compress(res.body))
let accepted = acceptEncoding.split(', ')
let compression
/**/ if (accepted.includes('br')) compression = 'br'
else if (accepted.includes('gzip')) compression = 'gzip'
else return res
if (compressionTypes[params.compression] && accepted.includes(params.compression)) {
compression = params.compression
}
res.body = b64enc(compress(res.body, compression))
res.isBase64Encoded = true

@@ -199,0 +207,0 @@ }

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc