@architect/functions
Advanced tools
Comparing version 5.3.4 to 5.4.0-RC.0
{ | ||
"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 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
72461
2098
1