@middy/http-content-encoding 4.0.0-alpha.3 → 4.0.0
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 +10 -10
- package/index.js +7 -7
- package/package.json +5 -7
package/index.cjs
CHANGED
|
@@ -6,13 +6,13 @@ Object.defineProperty(module, "exports", {
|
|
|
6
6
|
enumerable: true,
|
|
7
7
|
get: ()=>_default
|
|
8
8
|
});
|
|
9
|
-
const
|
|
10
|
-
const
|
|
9
|
+
const _nodeStream = require("node:stream");
|
|
10
|
+
const _nodeZlib = require("node:zlib");
|
|
11
11
|
const _util = require("@middy/util");
|
|
12
12
|
const contentEncodingStreams = {
|
|
13
|
-
br:
|
|
14
|
-
gzip:
|
|
15
|
-
deflate:
|
|
13
|
+
br: _nodeZlib.createBrotliCompress,
|
|
14
|
+
gzip: _nodeZlib.createGzip,
|
|
15
|
+
deflate: _nodeZlib.createDeflate
|
|
16
16
|
};
|
|
17
17
|
const defaults = {
|
|
18
18
|
br: undefined,
|
|
@@ -40,11 +40,11 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
40
40
|
contentEncoding = encoding;
|
|
41
41
|
break;
|
|
42
42
|
}
|
|
43
|
-
const stream = (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
43
|
+
const stream = _nodeStream.Readable.from(response.body).pipe(contentEncodingStream);
|
|
44
|
+
let body = '';
|
|
45
|
+
for await (const chunk of stream){
|
|
46
|
+
body += chunk;
|
|
47
|
+
}
|
|
48
48
|
if (body.length < response.body.length) {
|
|
49
49
|
response.headers['Content-Encoding'] = contentEncoding;
|
|
50
50
|
response.body = body;
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { brotliCompressStream, gzipCompressStream, deflateCompressStream } from '
|
|
1
|
+
import { Readable } from 'node:stream';
|
|
2
|
+
import { createBrotliCompress as brotliCompressStream, createGzip as gzipCompressStream, createDeflate as deflateCompressStream } from 'node:zlib';
|
|
3
3
|
import { normalizeHttpResponse } from '@middy/util';
|
|
4
4
|
const contentEncodingStreams = {
|
|
5
5
|
br: brotliCompressStream,
|
|
@@ -32,11 +32,11 @@ const httpContentEncodingMiddleware = (opts)=>{
|
|
|
32
32
|
contentEncoding = encoding;
|
|
33
33
|
break;
|
|
34
34
|
}
|
|
35
|
-
const stream =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
const stream = Readable.from(response.body).pipe(contentEncodingStream);
|
|
36
|
+
let body = '';
|
|
37
|
+
for await (const chunk of stream){
|
|
38
|
+
body += chunk;
|
|
39
|
+
}
|
|
40
40
|
if (body.length < response.body.length) {
|
|
41
41
|
response.headers['Content-Encoding'] = contentEncoding;
|
|
42
42
|
response.body = body;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-content-encoding",
|
|
3
|
-
"version": "4.0.0
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Http content encoding middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=16"
|
|
8
8
|
},
|
|
9
9
|
"engineStrict": true,
|
|
10
10
|
"publishConfig": {
|
|
@@ -65,12 +65,10 @@
|
|
|
65
65
|
},
|
|
66
66
|
"homepage": "https://middy.js.org",
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@
|
|
69
|
-
"@datastream/core": "0.0.8",
|
|
70
|
-
"@middy/util": "4.0.0-alpha.3"
|
|
68
|
+
"@middy/util": "4.0.0"
|
|
71
69
|
},
|
|
72
70
|
"devDependencies": {
|
|
73
|
-
"@middy/core": "4.0.0
|
|
71
|
+
"@middy/core": "4.0.0"
|
|
74
72
|
},
|
|
75
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "582286144bcd79968a8c7c2f8867a23c80079a47"
|
|
76
74
|
}
|