@middy/http-json-body-parser 7.1.0 → 7.1.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/README.md +25 -32
- package/index.d.ts +2 -1
- package/index.js +4 -7
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,39 +1,32 @@
|
|
|
1
1
|
<div align="center">
|
|
2
|
-
<h1>Middy http-json-body-parser middleware</h1>
|
|
2
|
+
<h1>Middy `http-json-body-parser` middleware</h1>
|
|
3
3
|
<img alt="Middy logo" src="https://raw.githubusercontent.com/middyjs/middy/main/docs/img/middy-logo.svg"/>
|
|
4
4
|
<p><strong>HTTP json body parser middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda</strong></p>
|
|
5
5
|
<p>
|
|
6
|
-
|
|
7
|
-
<img src="https://
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<img src="https://
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
<img src="https://img.shields.io/badge/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
<img src="https://
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<img src="https://
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
<a href="https://gitter.im/middyjs/Lobby">
|
|
31
|
-
<img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;">
|
|
32
|
-
</a>
|
|
33
|
-
<a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052">
|
|
34
|
-
<img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;">
|
|
35
|
-
</a>
|
|
36
|
-
</p>
|
|
6
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/test-unit.yml"><img src="https://github.com/middyjs/middy/actions/workflows/test-unit.yml/badge.svg" alt="GitHub Actions unit test status"></a>
|
|
7
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/test-dast.yml"><img src="https://github.com/middyjs/middy/actions/workflows/test-dast.yml/badge.svg" alt="GitHub Actions dast test status"></a>
|
|
8
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/test-perf.yml"><img src="https://github.com/middyjs/middy/actions/workflows/test-perf.yml/badge.svg" alt="GitHub Actions perf test status"></a>
|
|
9
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/test-sast.yml"><img src="https://github.com/middyjs/middy/actions/workflows/test-sast.yml/badge.svg" alt="GitHub Actions SAST test status"></a>
|
|
10
|
+
<a href="https://github.com/middyjs/middy/actions/workflows/test-lint.yml"><img src="https://github.com/middyjs/middy/actions/workflows/test-lint.yml/badge.svg" alt="GitHub Actions lint test status"></a>
|
|
11
|
+
<br/>
|
|
12
|
+
<a href="https://www.npmjs.com/package/@middy/http-json-body-parser"><img alt="npm version" src="https://img.shields.io/npm/v/@middy/http-json-body-parser.svg"></a>
|
|
13
|
+
<a href="https://packagephobia.com/result?p=@middy/http-json-body-parser"><img src="https://packagephobia.com/badge?p=@middy/http-json-body-parser" alt="npm install size"></a>
|
|
14
|
+
<a href="https://www.npmjs.com/package/@middy/http-json-body-parser">
|
|
15
|
+
<img alt="npm weekly downloads" src="https://img.shields.io/npm/dw/@middy/http-json-body-parser.svg"></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/@middy/http-json-body-parser#provenance">
|
|
17
|
+
<img alt="npm provenance" src="https://img.shields.io/badge/provenance-Yes-brightgreen"></a>
|
|
18
|
+
<br/>
|
|
19
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/middyjs/middy"><img src="https://api.scorecard.dev/projects/github.com/middyjs/middy/badge" alt="Open Source Security Foundation (OpenSSF) Scorecard"></a>
|
|
20
|
+
<a href="https://slsa.dev"><img src="https://slsa.dev/images/gh-badge-level3.svg" alt="SLSA 3"></a>
|
|
21
|
+
<a href="https://github.com/middyjs/middy/blob/main/docs/CODE_OF_CONDUCT.md"><img src="https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg"></a>
|
|
22
|
+
<a href="https://biomejs.dev"><img alt="Checked with Biome" src="https://img.shields.io/badge/Checked_with-Biome-60a5fa?style=flat&logo=biome"></a>
|
|
23
|
+
<a href="https://conventionalcommits.org"><img alt="Conventional Commits" src="https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?logo=conventionalcommits&logoColor=white"></a>
|
|
24
|
+
<a href="https://github.com/middyjs/middy/blob/main/package.json#L32">
|
|
25
|
+
<img alt="code coverage" src="https://img.shields.io/badge/code%20coverage-95%25-brightgreen"></a>
|
|
26
|
+
<br/>
|
|
27
|
+
<a href="https://gitter.im/middyjs/Lobby"><img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat on Gitter" style="max-width:100%;"></a>
|
|
28
|
+
<a href="https://stackoverflow.com/questions/tagged/middy?sort=Newest&uqlId=35052"><img src="https://img.shields.io/badge/StackOverflow-[middy]-yellow" alt="Ask questions on StackOverflow" style="max-width:100%;"></a>
|
|
29
|
+
</p>
|
|
37
30
|
<p>You can read the documentation at: <a href="https://middy.js.org/docs/middlewares/http-json-body-parser">https://middy.js.org/docs/middlewares/http-json-body-parser</a></p>
|
|
38
31
|
</div>
|
|
39
32
|
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2017 - 2026 will Farrell, Luciano Mammino, and Middy contributors.
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import { createError } from "@middy/util";
|
|
3
|
+
import { createError, decodeBody } from "@middy/util";
|
|
4
4
|
|
|
5
5
|
const mimePattern = /^application\/(.+\+)?json($|;.+)/;
|
|
6
6
|
|
|
@@ -26,20 +26,17 @@ const httpJsonBodyParserMiddleware = (opts = {}) => {
|
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
if (typeof body === "undefined") {
|
|
29
|
-
throw createError(
|
|
29
|
+
throw createError(422, "Invalid or malformed JSON was provided", {
|
|
30
30
|
cause: { package: "@middy/http-json-body-parser", data: body },
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
try {
|
|
35
|
-
const data = request.event
|
|
36
|
-
? Buffer.from(body, "base64").toString()
|
|
37
|
-
: body;
|
|
35
|
+
const data = decodeBody(request.event);
|
|
38
36
|
|
|
39
37
|
request.event.body = JSON.parse(data, options.reviver);
|
|
40
38
|
} catch (err) {
|
|
41
|
-
|
|
42
|
-
throw createError(415, "Invalid or malformed JSON was provided", {
|
|
39
|
+
throw createError(422, "Invalid or malformed JSON was provided", {
|
|
43
40
|
cause: {
|
|
44
41
|
package: "@middy/http-json-body-parser",
|
|
45
42
|
data: body,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@middy/http-json-body-parser",
|
|
3
|
-
"version": "7.1.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "7.1.2",
|
|
4
|
+
"description": "HTTP JSON body parser middleware for the middy framework",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=22"
|
|
@@ -67,10 +67,11 @@
|
|
|
67
67
|
"url": "https://github.com/sponsors/willfarrell"
|
|
68
68
|
},
|
|
69
69
|
"dependencies": {
|
|
70
|
-
"@middy/util": "7.1.
|
|
70
|
+
"@middy/util": "7.1.2"
|
|
71
71
|
},
|
|
72
72
|
"devDependencies": {
|
|
73
|
-
"@
|
|
73
|
+
"@middy/core": "7.1.2",
|
|
74
|
+
"@types/aws-lambda": "^8.0.0",
|
|
74
75
|
"type-fest": "^5.0.0"
|
|
75
76
|
},
|
|
76
77
|
"gitHead": "7a6c0fbb8ab71d6a2171e678697de9f237568431"
|