@middy/s3-object-response 2.5.2 → 3.0.0-alpha.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2017-2021 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
3
+ Copyright (c) 2017-2022 Luciano Mammino, will Farrell and the [Middy team](https://github.com/middyjs/middy/graphs/contributors)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -104,7 +104,7 @@ Everyone is very welcome to contribute to this repository. Feel free to [raise i
104
104
 
105
105
  ## License
106
106
 
107
- Licensed under [MIT License](LICENSE). Copyright (c) 2017-2021 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
107
+ Licensed under [MIT License](LICENSE). Copyright (c) 2017-2022 Luciano Mammino, will Farrell, and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
108
108
 
109
109
  <a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
110
110
  <img src="https://app.fossa.io/api/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy.svg?type=large" alt="FOSSA Status" style="max-width:100%;">
package/index.d.ts CHANGED
@@ -1,13 +1,10 @@
1
1
  import { S3 } from 'aws-sdk'
2
- import { captureAWSClient } from 'aws-xray-sdk'
3
2
  import middy from '@middy/core'
3
+ import { Options as MiddyOptions } from '@middy/util'
4
4
 
5
- interface Options<S = S3> {
6
- AwsClient?: new() => S
7
- awsClientOptions?: Partial<S3.Types.ClientConfiguration>
8
- awsClientAssumeRole?: string
9
- awsClientCapture?: typeof captureAWSClient
10
- disablePrefetch?: boolean
5
+ interface Options<S = S3>
6
+ extends Pick<MiddyOptions<S, S3.Types.ClientConfiguration>,
7
+ 'AwsClient' | 'awsClientOptions' | 'awsClientAssumeRole' | 'awsClientCapture' | 'disablePrefetch'> {
11
8
  bodyType?: string
12
9
  }
13
10
 
package/index.js CHANGED
@@ -1,31 +1,18 @@
1
- "use strict";
2
-
3
- let https = require('https');
4
-
5
- const {
6
- URL
7
- } = require('url');
8
-
9
- const {
10
- canPrefetch,
11
- createPrefetchClient,
12
- createClient
13
- } = require('@middy/util');
14
-
15
- const S3 = require('aws-sdk/clients/s3'); // v2
16
- // const { S3 } = require('@aws-sdk/client-s3') // v3
17
-
18
-
1
+ import __https from 'https';
2
+ import { URL } from 'url';
3
+ import { canPrefetch, createPrefetchClient, createClient } from '@middy/util';
4
+ import S3 from 'aws-sdk/clients/s3.js';
19
5
  const defaults = {
20
6
  AwsClient: S3,
21
- // Allow for XRay
22
7
  awsClientOptions: {},
23
8
  awsClientAssumeRole: undefined,
24
9
  awsClientCapture: undefined,
25
10
  httpsCapture: undefined,
26
11
  disablePrefetch: false,
27
- bodyType: undefined
12
+ bodyType: undefined,
13
+ __https
28
14
  };
15
+ let https = __https;
29
16
 
30
17
  const s3ObjectResponseMiddleware = (opts = {}) => {
31
18
  const options = { ...defaults,
@@ -37,7 +24,7 @@ const s3ObjectResponseMiddleware = (opts = {}) => {
37
24
  }
38
25
 
39
26
  if (options.httpsCapture) {
40
- https = options.httpsCapture(https);
27
+ https = options.httpsCapture(options.__https);
41
28
  }
42
29
 
43
30
  let client;
@@ -66,19 +53,19 @@ const s3ObjectResponseMiddleware = (opts = {}) => {
66
53
  };
67
54
 
68
55
  const s3ObjectResponseMiddlewareAfter = async request => {
69
- var _request$response$Bod;
56
+ var _request$response;
70
57
 
71
58
  if (!client) {
72
59
  client = await createClient(options, request);
73
60
  }
74
61
 
75
- request.response.Body = (_request$response$Bod = request.response.Body) !== null && _request$response$Bod !== void 0 ? _request$response$Bod : request.response.body;
62
+ (_request$response = request.response).Body ?? (_request$response.Body = request.response.body);
76
63
  delete request.response.body;
77
64
  return client.writeGetObjectResponse({ ...request.response,
78
65
  ...request.internal.s3ObjectResponse
79
66
  }).promise().then(() => ({
80
67
  statusCode: 200
81
- })); // TODO test if needed
68
+ }));
82
69
  };
83
70
 
84
71
  return {
@@ -113,4 +100,4 @@ const fetchPromise = fetchOptions => {
113
100
  });
114
101
  };
115
102
 
116
- module.exports = s3ObjectResponseMiddleware;
103
+ export default s3ObjectResponseMiddleware;
package/package.json CHANGED
@@ -1,18 +1,19 @@
1
1
  {
2
2
  "name": "@middy/s3-object-response",
3
- "version": "2.5.2",
3
+ "version": "3.0.0-alpha.1",
4
4
  "description": "S3 object response handling middleware for the middy framework",
5
- "type": "commonjs",
5
+ "type": "module",
6
6
  "engines": {
7
- "node": ">=12"
7
+ "node": ">=14"
8
8
  },
9
9
  "engineStrict": true,
10
10
  "publishConfig": {
11
11
  "access": "public"
12
12
  },
13
- "main": "index.js",
13
+ "exports": "./index.js",
14
14
  "types": "index.d.ts",
15
15
  "files": [
16
+ "index.js",
16
17
  "index.d.ts"
17
18
  ],
18
19
  "scripts": {
@@ -46,12 +47,12 @@
46
47
  },
47
48
  "homepage": "https://github.com/middyjs/middy#readme",
48
49
  "dependencies": {
49
- "@middy/util": "^2.5.2"
50
+ "@middy/util": "^3.0.0-alpha.1"
50
51
  },
51
52
  "devDependencies": {
52
- "@middy/core": "^2.5.2",
53
+ "@middy/core": "^3.0.0-alpha.1",
53
54
  "aws-sdk": "^2.939.0",
54
55
  "aws-xray-sdk": "^3.3.3"
55
56
  },
56
- "gitHead": "a2bb757a7a13638ae64277f8eecfcf11c1af17d4"
57
+ "gitHead": "a14125c6b2e21b181824f9985a919a47f1e4711f"
57
58
  }