@middy/http-content-encoding 3.1.0 → 3.2.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.
- package/index.cjs +26 -24
- package/index.js +3 -3
- package/package.json +5 -4
package/index.cjs
CHANGED
|
@@ -2,27 +2,30 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _stream = _interopRequireWildcard(require("stream"));
|
|
10
|
+
const _events = _interopRequireDefault(require("events"));
|
|
11
|
+
const _util = require("util");
|
|
12
|
+
const _zlib = require("zlib");
|
|
13
|
+
const _util1 = require("@middy/util");
|
|
11
14
|
function _interopRequireDefault(obj) {
|
|
12
15
|
return obj && obj.__esModule ? obj : {
|
|
13
16
|
default: obj
|
|
14
17
|
};
|
|
15
18
|
}
|
|
16
|
-
function _getRequireWildcardCache() {
|
|
19
|
+
function _getRequireWildcardCache(nodeInterop) {
|
|
17
20
|
if (typeof WeakMap !== "function") return null;
|
|
18
|
-
var
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var cacheBabelInterop = new WeakMap();
|
|
22
|
+
var cacheNodeInterop = new WeakMap();
|
|
23
|
+
return (_getRequireWildcardCache = function(nodeInterop) {
|
|
24
|
+
return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
|
|
25
|
+
})(nodeInterop);
|
|
23
26
|
}
|
|
24
|
-
function _interopRequireWildcard(obj) {
|
|
25
|
-
if (obj && obj.__esModule) {
|
|
27
|
+
function _interopRequireWildcard(obj, nodeInterop) {
|
|
28
|
+
if (!nodeInterop && obj && obj.__esModule) {
|
|
26
29
|
return obj;
|
|
27
30
|
}
|
|
28
31
|
if (obj === null || typeof obj !== "object" && typeof obj !== "function") {
|
|
@@ -30,14 +33,14 @@ function _interopRequireWildcard(obj) {
|
|
|
30
33
|
default: obj
|
|
31
34
|
};
|
|
32
35
|
}
|
|
33
|
-
var cache = _getRequireWildcardCache();
|
|
36
|
+
var cache = _getRequireWildcardCache(nodeInterop);
|
|
34
37
|
if (cache && cache.has(obj)) {
|
|
35
38
|
return cache.get(obj);
|
|
36
39
|
}
|
|
37
40
|
var newObj = {};
|
|
38
41
|
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor;
|
|
39
42
|
for(var key in obj){
|
|
40
|
-
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
43
|
+
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
41
44
|
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null;
|
|
42
45
|
if (desc && (desc.get || desc.set)) {
|
|
43
46
|
Object.defineProperty(newObj, key, desc);
|
|
@@ -53,9 +56,9 @@ function _interopRequireWildcard(obj) {
|
|
|
53
56
|
return newObj;
|
|
54
57
|
}
|
|
55
58
|
const contentEncodingStreams = {
|
|
56
|
-
br: (opts = {})=>(0, _zlib
|
|
57
|
-
gzip: (opts = {})=>(0, _zlib
|
|
58
|
-
deflate: (opts = {})=>(0, _zlib
|
|
59
|
+
br: (opts = {})=>(0, _zlib.createBrotliCompress)(opts),
|
|
60
|
+
gzip: (opts = {})=>(0, _zlib.createGzip)(opts),
|
|
61
|
+
deflate: (opts = {})=>(0, _zlib.createDeflate)(opts)
|
|
59
62
|
};
|
|
60
63
|
const defaults = {
|
|
61
64
|
br: undefined,
|
|
@@ -70,7 +73,7 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
70
73
|
};
|
|
71
74
|
const supportedContentEncodings = Object.keys(contentEncodingStreams);
|
|
72
75
|
const httpContentEncodingMiddlewareAfter = async (request)=>{
|
|
73
|
-
(0, _util1
|
|
76
|
+
(0, _util1.normalizeHttpResponse)(request);
|
|
74
77
|
const { event: { preferredEncoding , preferredEncodings } , response } = request;
|
|
75
78
|
if (response.isBase64Encoded || !preferredEncoding || !supportedContentEncodings.includes(preferredEncoding)) {
|
|
76
79
|
return;
|
|
@@ -110,7 +113,7 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
110
113
|
request.response = response;
|
|
111
114
|
};
|
|
112
115
|
const httpContentEncodingMiddlewareOnError = async (request)=>{
|
|
113
|
-
if (request.response === undefined) return;
|
|
116
|
+
if (typeof request.response === 'undefined') return;
|
|
114
117
|
return httpContentEncodingMiddlewareAfter(request);
|
|
115
118
|
};
|
|
116
119
|
return {
|
|
@@ -123,14 +126,13 @@ const isReadableStream = (stream)=>{
|
|
|
123
126
|
};
|
|
124
127
|
const polyfillPipelinePromise = ()=>{
|
|
125
128
|
if (process.version < 'v15.0.0') {
|
|
126
|
-
return (0, _util
|
|
129
|
+
return (0, _util.promisify)(_stream.default.pipeline);
|
|
127
130
|
} else {
|
|
128
131
|
return _stream.default.promises.pipeline;
|
|
129
132
|
}
|
|
130
133
|
};
|
|
131
134
|
const pipeline = polyfillPipelinePromise();
|
|
132
|
-
|
|
133
|
-
module.exports = _default;
|
|
135
|
+
const _default = httpContentEncodingMiddleware;
|
|
134
136
|
|
|
135
137
|
|
|
136
138
|
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -61,7 +61,7 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
61
61
|
request.response = response;
|
|
62
62
|
};
|
|
63
63
|
const httpContentEncodingMiddlewareOnError = async (request)=>{
|
|
64
|
-
if (request.response === undefined) return;
|
|
64
|
+
if (typeof request.response === 'undefined') return;
|
|
65
65
|
return httpContentEncodingMiddlewareAfter(request);
|
|
66
66
|
};
|
|
67
67
|
return {
|
|
@@ -69,8 +69,8 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
69
69
|
onError: httpContentEncodingMiddlewareOnError
|
|
70
70
|
};
|
|
71
71
|
};
|
|
72
|
-
const isReadableStream = (
|
|
73
|
-
return
|
|
72
|
+
const isReadableStream = (stream)=>{
|
|
73
|
+
return stream instanceof eventEmitter && stream.readable !== false;
|
|
74
74
|
};
|
|
75
75
|
const polyfillPipelinePromise = ()=>{
|
|
76
76
|
if (process.version < 'v15.0.0') {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-content-encoding",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Http content encoding middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"main": "./index.cjs",
|
|
14
|
+
"module": "./index.js",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
@@ -64,10 +65,10 @@
|
|
|
64
65
|
},
|
|
65
66
|
"homepage": "https://middy.js.org",
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"@middy/util": "3.1
|
|
68
|
+
"@middy/util": "3.2.1"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
|
-
"@middy/core": "3.1
|
|
71
|
+
"@middy/core": "3.2.1"
|
|
71
72
|
},
|
|
72
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b4169ec20b798650e934a7c25ee80ae98d11e03a"
|
|
73
74
|
}
|