@middy/http-json-body-parser 6.0.0-beta.1 → 6.1.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/README.md +1 -1
- package/index.js +11 -2
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
|
|
40
40
|
## License
|
|
41
41
|
|
|
42
|
-
Licensed under [MIT License](LICENSE). Copyright (c) 2017-
|
|
42
|
+
Licensed under [MIT License](LICENSE). Copyright (c) 2017-2025 [Luciano Mammino](https://github.com/lmammino), [will Farrell](https://github.com/willfarrell), and the [Middy team](https://github.com/middyjs/middy/graphs/contributors).
|
|
43
43
|
|
|
44
44
|
<a href="https://app.fossa.io/projects/git%2Bgithub.com%2Fmiddyjs%2Fmiddy?ref=badge_large">
|
|
45
45
|
<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.js
CHANGED
|
@@ -11,8 +11,13 @@ const httpJsonBodyParserMiddleware = (opts = {}) => {
|
|
|
11
11
|
const options = { ...defaults, ...opts }
|
|
12
12
|
const httpJsonBodyParserMiddlewareBefore = async (request) => {
|
|
13
13
|
const { headers, body } = request.event
|
|
14
|
+
if (typeof body === 'undefined') {
|
|
15
|
+
throw createError(415, 'Invalid or malformed JSON was provided', {
|
|
16
|
+
cause: { package: '@middy/http-json-body-parser', data: body }
|
|
17
|
+
})
|
|
18
|
+
}
|
|
14
19
|
|
|
15
|
-
const contentType = headers?.['
|
|
20
|
+
const contentType = headers?.['content-type'] ?? headers?.['Content-Type']
|
|
16
21
|
|
|
17
22
|
if (!mimePattern.test(contentType)) {
|
|
18
23
|
if (options.disableContentTypeError) {
|
|
@@ -32,7 +37,11 @@ const httpJsonBodyParserMiddleware = (opts = {}) => {
|
|
|
32
37
|
} catch (err) {
|
|
33
38
|
// UnprocessableEntity
|
|
34
39
|
throw createError(415, 'Invalid or malformed JSON was provided', {
|
|
35
|
-
cause: {
|
|
40
|
+
cause: {
|
|
41
|
+
package: '@middy/http-json-body-parser',
|
|
42
|
+
data: body,
|
|
43
|
+
message: err.message
|
|
44
|
+
}
|
|
36
45
|
})
|
|
37
46
|
}
|
|
38
47
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-json-body-parser",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.1",
|
|
4
4
|
"description": "Http JSON body parser middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
"index.d.ts"
|
|
29
29
|
],
|
|
30
30
|
"scripts": {
|
|
31
|
-
"test": "npm run test:unit",
|
|
31
|
+
"test": "npm run test:unit && npm run test:fuzz",
|
|
32
32
|
"test:unit": "node --test __tests__/index.js",
|
|
33
|
+
"test:fuzz": "node --test __tests__/fuzz.js",
|
|
33
34
|
"test:benchmark": "node __benchmarks__/index.js"
|
|
34
35
|
},
|
|
35
36
|
"license": "MIT",
|
|
@@ -53,7 +54,7 @@
|
|
|
53
54
|
},
|
|
54
55
|
"repository": {
|
|
55
56
|
"type": "git",
|
|
56
|
-
"url": "github
|
|
57
|
+
"url": "git+https://github.com/middyjs/middy.git",
|
|
57
58
|
"directory": "packages/http-json-body-parser"
|
|
58
59
|
},
|
|
59
60
|
"bugs": {
|
|
@@ -65,7 +66,7 @@
|
|
|
65
66
|
"url": "https://github.com/sponsors/willfarrell"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
|
-
"@middy/util": "6.
|
|
69
|
+
"@middy/util": "6.1.0"
|
|
69
70
|
},
|
|
70
71
|
"devDependencies": {
|
|
71
72
|
"@types/aws-lambda": "^8.10.101",
|