@middy/s3-object-response 7.1.1 → 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-object-response">https://middy.js.org/docs/middlewares/s3-object-response</a></p>
31
31
  </div>
32
32
 
33
+ ## Install
34
+
35
+ ```bash
36
+ npm install --save @middy/s3-object-response @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-object-response).
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
@@ -1,6 +1,5 @@
1
1
  // Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
2
2
  // SPDX-License-Identifier: MIT
3
- import type { ClientRequest } from "node:http";
4
3
  import type { S3Client, S3ClientConfig } from "@aws-sdk/client-s3";
5
4
  import type middy from "@middy/core";
6
5
  import type { Options as MiddyOptions } from "@middy/util";
@@ -17,32 +16,14 @@ export interface S3ObjectResponseOptions<AwsS3Client = S3Client>
17
16
  | "awsClientAssumeRole"
18
17
  | "awsClientCapture"
19
18
  | "disablePrefetch"
20
- > {
21
- bodyType?: "stream" | "promise";
22
- }
19
+ > {}
23
20
 
24
- export type Context<TOptions extends S3ObjectResponseOptions | undefined> =
25
- LambdaContext & {
26
- s3Object: TOptions extends { bodyType: "stream" }
27
- ? ClientRequest
28
- : TOptions extends { bodyType: "promise" }
29
- ? Promise<any>
30
- : never;
31
- } & {
32
- s3ObjectFetch: Promise<Response>;
33
- };
21
+ export type Context = LambdaContext & {
22
+ s3ObjectFetch: Promise<Response> | undefined;
23
+ };
34
24
 
35
- export interface Internal extends Record<string, any> {
36
- s3ObjectResponse: {
37
- RequestRoute: string;
38
- RequestToken: string;
39
- };
40
- }
41
-
42
- declare function s3ObjectResponse<
43
- TOptions extends S3ObjectResponseOptions | undefined,
44
- >(
45
- options?: TOptions,
46
- ): middy.MiddlewareObj<unknown, any, Error, Context<TOptions>, Internal>;
25
+ declare function s3ObjectResponse(
26
+ options?: S3ObjectResponseOptions,
27
+ ): middy.MiddlewareObj<unknown, unknown, Error, Context>;
47
28
 
48
29
  export default s3ObjectResponse;
package/index.js CHANGED
@@ -3,9 +3,9 @@
3
3
  import { S3Client, WriteGetObjectResponseCommand } from "@aws-sdk/client-s3";
4
4
  import {
5
5
  canPrefetch,
6
+ catchInvalidSignatureException,
6
7
  createClient,
7
8
  createPrefetchClient,
8
- // catchInvalidSignatureException
9
9
  } from "@middy/util";
10
10
 
11
11
  const defaults = {
@@ -40,8 +40,10 @@ const s3ObjectResponseMiddleware = (opts = {}) => {
40
40
  RequestToken: request.event.getObjectContext?.outputToken,
41
41
  Body: request.response.Body ?? request.response.body,
42
42
  });
43
- await client.send(command); // Doesn't return a promise?
44
- // .catch((e) => catchInvalidSignatureException(e, client, command))
43
+ await client
44
+ .send(command)
45
+ // ?. required due to mockClient able to return undefined
46
+ ?.catch((e) => catchInvalidSignatureException(e, client, command));
45
47
 
46
48
  return { statusCode: 200 };
47
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/s3-object-response",
3
- "version": "7.1.1",
3
+ "version": "7.1.3",
4
4
  "description": "S3 object response handling middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -72,14 +72,14 @@
72
72
  "optional": true
73
73
  }
74
74
  },
75
+ "dependencies": {
76
+ "@middy/util": "7.1.3"
77
+ },
75
78
  "devDependencies": {
76
79
  "@aws-sdk/client-s3": "^3.0.0",
77
- "@middy/core": "7.1.1",
80
+ "@middy/core": "7.1.3",
78
81
  "@types/aws-lambda": "^8.0.0",
82
+ "@types/node": "^22.0.0",
79
83
  "aws-xray-sdk": "^3.3.3"
80
- },
81
- "dependencies": {
82
- "@middy/util": "7.1.1"
83
- },
84
- "gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
84
+ }
85
85
  }