@middy/s3 7.1.2 → 7.1.3

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/README.md CHANGED
@@ -30,6 +30,23 @@
30
30
  <p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/s3">https://middy.js.org/docs/middlewares/s3</a></p>
31
31
  </div>
32
32
 
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install --save @middy/s3 @aws-sdk/client-s3
37
+ ```
38
+
39
+
40
+ ## Documentation and examples
41
+
42
+ For documentation and examples, refer to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org/docs/middlewares/s3).
43
+
44
+
45
+ ## Contributing
46
+
47
+ Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
48
+
49
+
33
50
  ## License
34
51
 
35
52
  Licensed under [MIT License](LICENSE). Copyright (c) 2017-2026 [will Farrell](https://github.com/willfarrell), [Luciano Mammino](https://github.com/lmammino), and [Middy contributors](https://github.com/middyjs/middy/graphs/contributors).
package/index.d.ts CHANGED
@@ -58,7 +58,7 @@ declare function s3Middleware<TOptions extends S3Options | undefined>(
58
58
  options?: TOptions,
59
59
  ): middy.MiddlewareObj<
60
60
  unknown,
61
- any,
61
+ unknown,
62
62
  Error,
63
63
  Context<TOptions>,
64
64
  Internal<TOptions>
package/index.js CHANGED
@@ -25,15 +25,16 @@ const defaults = {
25
25
  cacheExpiry: -1,
26
26
  setToContext: false,
27
27
  };
28
- const contentTypePattern = /^application\/(.+\+)?json($|;.+)/;
28
+ const jsonContentTypePattern = /^application\/([a-z0-9.+-]+\+)?json(;|$)/i;
29
29
  const s3Middleware = (opts = {}) => {
30
30
  const options = {
31
31
  ...defaults,
32
32
  ...opts,
33
33
  };
34
+ const fetchDataKeys = Object.keys(options.fetchData);
34
35
  const fetchRequest = (request, cachedValues = {}) => {
35
36
  const values = {};
36
- for (const internalKey of Object.keys(options.fetchData)) {
37
+ for (const internalKey of fetchDataKeys) {
37
38
  if (cachedValues[internalKey]) continue;
38
39
  const command = new GetObjectCommand(options.fetchData[internalKey]);
39
40
  values[internalKey] = client
@@ -41,7 +42,7 @@ const s3Middleware = (opts = {}) => {
41
42
  .catch((e) => catchInvalidSignatureException(e, client, command))
42
43
  .then(async (resp) => {
43
44
  let value = await resp.Body.transformToString();
44
- if (contentTypePattern.test(resp.ContentType)) {
45
+ if (jsonContentTypePattern.test(resp.ContentType)) {
45
46
  value = jsonSafeParse(value);
46
47
  }
47
48
  return value;
@@ -67,7 +68,7 @@ const s3Middleware = (opts = {}) => {
67
68
  const { value } = processCache(options, fetchRequest, request);
68
69
  Object.assign(request.internal, value);
69
70
  if (options.setToContext) {
70
- const data = await getInternal(Object.keys(options.fetchData), request);
71
+ const data = await getInternal(fetchDataKeys, request);
71
72
  Object.assign(request.context, data);
72
73
  }
73
74
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/s3",
3
- "version": "7.1.2",
3
+ "version": "7.1.3",
4
4
  "description": "S3 middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -63,7 +63,7 @@
63
63
  "url": "https://github.com/sponsors/willfarrell"
64
64
  },
65
65
  "dependencies": {
66
- "@middy/util": "7.1.2"
66
+ "@middy/util": "7.1.3"
67
67
  },
68
68
  "peerDependencies": {
69
69
  "@aws-sdk/client-s3": "^3.0.0"
@@ -75,9 +75,9 @@
75
75
  },
76
76
  "devDependencies": {
77
77
  "@aws-sdk/client-s3": "^3.0.0",
78
- "@middy/core": "7.1.2",
78
+ "@middy/core": "7.1.3",
79
79
  "@types/aws-lambda": "^8.0.0",
80
+ "@types/node": "^22.0.0",
80
81
  "aws-xray-sdk": "^3.3.3"
81
- },
82
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
82
+ }
83
83
  }