@middy/http-json-body-parser 3.0.0-alpha.7 → 3.0.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 +3 -0
- package/index.js +1 -1
- package/package.json +13 -6
package/index.cjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=void 0;var _util=require("@middy/util");const mimePattern=/^application\/(.+\+)?json(;.*)?$/;const defaults={reviver:undefined};const httpJsonBodyParserMiddleware=(opts={})=>{const options={...defaults,...opts};const httpJsonBodyParserMiddlewareBefore=async request=>{const{headers,body}=request.event;const contentTypeHeader=headers["Content-Type"]??headers["content-type"];if(mimePattern.test(contentTypeHeader)){try{const data=request.event.isBase64Encoded?Buffer.from(body,"base64").toString():body;request.event.rawBody=body;request.event.body=JSON.parse(data,options.reviver)}catch(cause){const error=(0,_util).createError(422,"Invalid or malformed JSON was provided");error.cause=cause;throw error}}};return{before:httpJsonBodyParserMiddlewareBefore}};var _default=httpJsonBodyParserMiddleware;exports.default=_default
|
|
2
|
+
|
|
3
|
+
//# sourceMappingURL=index.cjs.map
|
package/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{createError}from
|
|
1
|
+
import{createError}from"@middy/util";const mimePattern=/^application\/(.+\+)?json(;.*)?$/;const defaults={reviver:undefined};const httpJsonBodyParserMiddleware=(opts={})=>{const options={...defaults,...opts};const httpJsonBodyParserMiddlewareBefore=async request=>{const{headers,body}=request.event;const contentTypeHeader=headers["Content-Type"]??headers["content-type"];if(mimePattern.test(contentTypeHeader)){try{const data=request.event.isBase64Encoded?Buffer.from(body,"base64").toString():body;request.event.rawBody=body;request.event.body=JSON.parse(data,options.reviver)}catch(cause){const error=createError(422,"Invalid or malformed JSON was provided");error.cause=cause;throw error}}};return{before:httpJsonBodyParserMiddlewareBefore}};export default httpJsonBodyParserMiddleware
|
|
2
2
|
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-json-body-parser",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Http JSON body parser middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -10,10 +10,17 @@
|
|
|
10
10
|
"publishConfig": {
|
|
11
11
|
"access": "public"
|
|
12
12
|
},
|
|
13
|
-
"exports":
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"import": "./index.js",
|
|
16
|
+
"require": "./index.cjs",
|
|
17
|
+
"types": "./index.d.ts"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
14
20
|
"types": "index.d.ts",
|
|
15
21
|
"files": [
|
|
16
22
|
"index.js",
|
|
23
|
+
"index.cjs",
|
|
17
24
|
"index.d.ts"
|
|
18
25
|
],
|
|
19
26
|
"scripts": {
|
|
@@ -48,12 +55,12 @@
|
|
|
48
55
|
"bugs": {
|
|
49
56
|
"url": "https://github.com/middyjs/middy/issues"
|
|
50
57
|
},
|
|
51
|
-
"homepage": "https://
|
|
58
|
+
"homepage": "https://middy.js.org",
|
|
52
59
|
"dependencies": {
|
|
53
|
-
"@middy/util": "^3.0.
|
|
60
|
+
"@middy/util": "^3.0.1"
|
|
54
61
|
},
|
|
55
62
|
"devDependencies": {
|
|
56
|
-
"@middy/core": "^3.0.
|
|
63
|
+
"@middy/core": "^3.0.1"
|
|
57
64
|
},
|
|
58
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "797455e2c2be445867bc03597e0a2d5b0560c9de"
|
|
59
66
|
}
|