@middy/http-multipart-body-parser 3.1.0 → 3.2.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/index.cjs +9 -7
- package/index.d.ts +9 -1
- package/package.json +7 -4
package/index.cjs
CHANGED
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _busboy = _interopRequireDefault(require("busboy"));
|
|
10
|
+
const _util = require("@middy/util");
|
|
8
11
|
function _interopRequireDefault(obj) {
|
|
9
12
|
return obj && obj.__esModule ? obj : {
|
|
10
13
|
default: obj
|
|
@@ -27,7 +30,7 @@ const httpMultipartBodyParserMiddleware = (opts = {})=>{
|
|
|
27
30
|
return parseMultipartData(request.event, options.busboy).then((multipartData)=>{
|
|
28
31
|
request.event.body = multipartData;
|
|
29
32
|
}).catch((cause)=>{
|
|
30
|
-
const error = (0, _util
|
|
33
|
+
const error = (0, _util.createError)(422, 'Invalid or malformed multipart/form-data was provided');
|
|
31
34
|
error.cause = cause;
|
|
32
35
|
throw error;
|
|
33
36
|
});
|
|
@@ -38,7 +41,7 @@ const httpMultipartBodyParserMiddleware = (opts = {})=>{
|
|
|
38
41
|
};
|
|
39
42
|
const parseMultipartData = (event, options)=>{
|
|
40
43
|
const multipartData = {};
|
|
41
|
-
const busboy = (0, _busboy
|
|
44
|
+
const busboy = (0, _busboy.default)({
|
|
42
45
|
...options,
|
|
43
46
|
headers: {
|
|
44
47
|
'content-type': event.headers['Content-Type'] ?? event.headers['content-type']
|
|
@@ -83,8 +86,7 @@ const parseMultipartData = (event, options)=>{
|
|
|
83
86
|
busboy.end();
|
|
84
87
|
});
|
|
85
88
|
};
|
|
86
|
-
|
|
87
|
-
module.exports = _default;
|
|
89
|
+
const _default = httpMultipartBodyParserMiddleware;
|
|
88
90
|
|
|
89
91
|
|
|
90
92
|
//# sourceMappingURL=index.cjs.map
|
package/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import middy from '@middy/core'
|
|
2
|
+
import { APIGatewayEvent } from 'aws-lambda'
|
|
3
|
+
import { JsonValue } from 'type-fest'
|
|
2
4
|
|
|
3
5
|
interface Options {
|
|
4
6
|
busboy?: {
|
|
@@ -19,6 +21,12 @@ interface Options {
|
|
|
19
21
|
}
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
export type Event = Omit<APIGatewayEvent, 'body'> & {
|
|
25
|
+
body: JsonValue
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare function multipartBodyParser (
|
|
29
|
+
options?: Options
|
|
30
|
+
): middy.MiddlewareObj<Event>
|
|
23
31
|
|
|
24
32
|
export default multipartBodyParser
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-multipart-body-parser",
|
|
3
|
-
"version": "3.1
|
|
3
|
+
"version": "3.2.1",
|
|
4
4
|
"description": "Http event normalizer middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
13
|
"main": "./index.cjs",
|
|
14
|
+
"module": "./index.js",
|
|
14
15
|
"exports": {
|
|
15
16
|
".": {
|
|
16
17
|
"import": {
|
|
@@ -61,11 +62,13 @@
|
|
|
61
62
|
},
|
|
62
63
|
"homepage": "https://middy.js.org",
|
|
63
64
|
"dependencies": {
|
|
64
|
-
"@middy/util": "3.1
|
|
65
|
+
"@middy/util": "3.2.1",
|
|
65
66
|
"busboy": "1.6.0"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
68
|
-
"@middy/core": "3.1
|
|
69
|
+
"@middy/core": "3.2.1",
|
|
70
|
+
"@types/aws-lambda": "^8.10.101",
|
|
71
|
+
"type-fest": "^2.18.0"
|
|
69
72
|
},
|
|
70
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "b4169ec20b798650e934a7c25ee80ae98d11e03a"
|
|
71
74
|
}
|