@middy/http-json-body-parser 3.1.1 → 3.2.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.
- package/index.cjs +7 -5
- package/index.d.ts +11 -1
- package/package.json +6 -4
package/index.cjs
CHANGED
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
-
module
|
|
6
|
-
|
|
5
|
+
Object.defineProperty(module, "exports", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: ()=>_default
|
|
8
|
+
});
|
|
9
|
+
const _util = require("@middy/util");
|
|
7
10
|
const mimePattern = /^application\/(.+\+)?json(;.*)?$/;
|
|
8
11
|
const defaults = {
|
|
9
12
|
reviver: undefined
|
|
@@ -22,7 +25,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
|
|
|
22
25
|
request.event.rawBody = body;
|
|
23
26
|
request.event.body = JSON.parse(data, reviver);
|
|
24
27
|
} catch (cause) {
|
|
25
|
-
const error = (0, _util
|
|
28
|
+
const error = (0, _util.createError)(422, 'Invalid or malformed JSON was provided');
|
|
26
29
|
error.cause = cause;
|
|
27
30
|
throw error;
|
|
28
31
|
}
|
|
@@ -31,8 +34,7 @@ const httpJsonBodyParserMiddleware = (opts = {})=>{
|
|
|
31
34
|
before: httpJsonBodyParserMiddlewareBefore
|
|
32
35
|
};
|
|
33
36
|
};
|
|
34
|
-
|
|
35
|
-
module.exports = _default;
|
|
37
|
+
const _default = httpJsonBodyParserMiddleware;
|
|
36
38
|
|
|
37
39
|
|
|
38
40
|
//# sourceMappingURL=index.cjs.map
|
package/index.d.ts
CHANGED
|
@@ -1,9 +1,19 @@
|
|
|
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
|
reviver?: (key: string, value: any) => any
|
|
5
7
|
}
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
export type Event = Omit<APIGatewayEvent, 'body'> & {
|
|
10
|
+
/**
|
|
11
|
+
* The body of the HTTP request.
|
|
12
|
+
*/
|
|
13
|
+
body: JsonValue
|
|
14
|
+
rawBody: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare function jsonBodyParser (options?: Options): middy.MiddlewareObj<Event>
|
|
8
18
|
|
|
9
19
|
export default jsonBodyParser
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-json-body-parser",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.2",
|
|
4
4
|
"description": "Http JSON body parser middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -64,10 +64,12 @@
|
|
|
64
64
|
},
|
|
65
65
|
"homepage": "https://middy.js.org",
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@middy/util": "3.
|
|
67
|
+
"@middy/util": "3.2.2"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@middy/core": "3.
|
|
70
|
+
"@middy/core": "3.2.2",
|
|
71
|
+
"@types/aws-lambda": "^8.10.101",
|
|
72
|
+
"type-fest": "^2.18.0"
|
|
71
73
|
},
|
|
72
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "4c960a361cc8844f7b2e6202d9544c852366fb01"
|
|
73
75
|
}
|