@middy/s3-object-response 2.5.3 → 3.0.0-alpha.2
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 +1 -1
- package/README.md +1 -1
- package/index.d.ts +4 -7
- package/index.js +12 -25
- package/package.json +8 -7
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2017-
|
|
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-
|
|
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
|
-
|
|
7
|
-
awsClientOptions
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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(
|
|
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
|
|
56
|
+
var _request$response;
|
|
70
57
|
|
|
71
58
|
if (!client) {
|
|
72
59
|
client = await createClient(options, request);
|
|
73
60
|
}
|
|
74
61
|
|
|
75
|
-
|
|
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
|
-
}));
|
|
68
|
+
}));
|
|
82
69
|
};
|
|
83
70
|
|
|
84
71
|
return {
|
|
@@ -113,4 +100,4 @@ const fetchPromise = fetchOptions => {
|
|
|
113
100
|
});
|
|
114
101
|
};
|
|
115
102
|
|
|
116
|
-
|
|
103
|
+
export default s3ObjectResponseMiddleware;
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/s3-object-response",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "S3 object response handling middleware for the middy framework",
|
|
5
|
-
"type": "
|
|
5
|
+
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
|
-
"node": ">=
|
|
7
|
+
"node": ">=14"
|
|
8
8
|
},
|
|
9
9
|
"engineStrict": true,
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"
|
|
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": "^
|
|
50
|
+
"@middy/util": "^3.0.0-alpha.2"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@middy/core": "^
|
|
53
|
+
"@middy/core": "^3.0.0-alpha.2",
|
|
53
54
|
"aws-sdk": "^2.939.0",
|
|
54
55
|
"aws-xray-sdk": "^3.3.3"
|
|
55
56
|
},
|
|
56
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "de30419273ecbff08f367f47c7e320ec981cf145"
|
|
57
58
|
}
|