@middy/http-json-body-parser 6.1.4 → 6.1.5

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.
Files changed (2) hide show
  1. package/index.js +6 -6
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -11,12 +11,6 @@ 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
- }
19
-
20
14
  const contentType = headers?.['content-type'] ?? headers?.['Content-Type']
21
15
 
22
16
  if (!mimePattern.test(contentType)) {
@@ -28,6 +22,12 @@ const httpJsonBodyParserMiddleware = (opts = {}) => {
28
22
  })
29
23
  }
30
24
 
25
+ if (typeof body === 'undefined') {
26
+ throw createError(415, 'Invalid or malformed JSON was provided', {
27
+ cause: { package: '@middy/http-json-body-parser', data: body }
28
+ })
29
+ }
30
+
31
31
  try {
32
32
  const data = request.event.isBase64Encoded
33
33
  ? Buffer.from(body, 'base64').toString()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-json-body-parser",
3
- "version": "6.1.4",
3
+ "version": "6.1.5",
4
4
  "description": "Http JSON body parser middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -66,7 +66,7 @@
66
66
  "url": "https://github.com/sponsors/willfarrell"
67
67
  },
68
68
  "dependencies": {
69
- "@middy/util": "6.1.4"
69
+ "@middy/util": "6.1.5"
70
70
  },
71
71
  "devDependencies": {
72
72
  "@types/aws-lambda": "^8.10.101",