@middy/http-json-body-parser 4.6.0 → 4.6.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.
Files changed (3) hide show
  1. package/index.cjs +2 -1
  2. package/index.js +2 -1
  3. package/package.json +4 -4
package/index.cjs CHANGED
@@ -21,7 +21,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
21
21
  };
22
22
  const httpJsonBodyParserMiddlewareBefore = async (request)=>{
23
23
  const { headers, body } = request.event;
24
- const contentType = headers['Content-Type'] ?? headers['content-type'];
24
+ const contentType = headers?.['Content-Type'] ?? headers?.['content-type'];
25
25
  if (!mimePattern.test(contentType)) {
26
26
  if (options.disableContentTypeError) {
27
27
  return;
@@ -34,6 +34,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
34
34
  const data = request.event.isBase64Encoded ? Buffer.from(body, 'base64').toString() : body;
35
35
  request.event.body = JSON.parse(data, options.reviver);
36
36
  } catch (cause) {
37
+ // UnprocessableEntity
37
38
  throw (0, _util.createError)(415, 'Invalid or malformed JSON was provided', {
38
39
  cause
39
40
  });
package/index.js CHANGED
@@ -11,7 +11,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
11
11
  };
12
12
  const httpJsonBodyParserMiddlewareBefore = async (request)=>{
13
13
  const { headers, body } = request.event;
14
- const contentType = headers['Content-Type'] ?? headers['content-type'];
14
+ const contentType = headers?.['Content-Type'] ?? headers?.['content-type'];
15
15
  if (!mimePattern.test(contentType)) {
16
16
  if (options.disableContentTypeError) {
17
17
  return;
@@ -24,6 +24,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
24
24
  const data = request.event.isBase64Encoded ? Buffer.from(body, 'base64').toString() : body;
25
25
  request.event.body = JSON.parse(data, options.reviver);
26
26
  } catch (cause) {
27
+ // UnprocessableEntity
27
28
  throw createError(415, 'Invalid or malformed JSON was provided', {
28
29
  cause
29
30
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@middy/http-json-body-parser",
3
- "version": "4.6.0",
3
+ "version": "4.6.2",
4
4
  "description": "Http JSON body parser middleware for the middy framework",
5
5
  "type": "module",
6
6
  "engines": {
@@ -68,12 +68,12 @@
68
68
  "url": "https://github.com/sponsors/willfarrell"
69
69
  },
70
70
  "dependencies": {
71
- "@middy/util": "4.6.0"
71
+ "@middy/util": "4.6.2"
72
72
  },
73
73
  "devDependencies": {
74
- "@middy/core": "4.6.0",
74
+ "@middy/core": "4.6.2",
75
75
  "@types/aws-lambda": "^8.10.101",
76
76
  "type-fest": "^4.0.0"
77
77
  },
78
- "gitHead": "34e52521a81a224e3d97de6171604c49e676f0d4"
78
+ "gitHead": "8b03a01abf5a9c08231ec5ced775e87f8be8f67d"
79
79
  }