Socket
Socket
Sign inDemoInstall

@middy/http-json-body-parser

Package Overview
Dependencies
1
Maintainers
3
Versions
213
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.0 to 4.0.1

8

package.json
{
"name": "@middy/http-json-body-parser",
"version": "4.0.0",
"version": "4.0.1",
"description": "Http JSON body parser middleware for the middy framework",

@@ -67,10 +67,10 @@ "type": "module",

"dependencies": {
"@middy/util": "4.0.0"
"@middy/util": "4.0.1"
},
"devDependencies": {
"@middy/core": "4.0.0",
"@middy/core": "4.0.1",
"@types/aws-lambda": "^8.10.101",
"type-fest": "^3.0.0"
},
"gitHead": "582286144bcd79968a8c7c2f8867a23c80079a47"
"gitHead": "c5ece2bfbb0d607dcdea5685bf194a6cc19acc8d"
}

@@ -39,64 +39,2 @@ <div align="center">

This middleware automatically parses HTTP requests with a JSON body and converts the body into an
object. Also handles gracefully broken JSON as *UnprocessableEntity* (422 errors)
if used in combination with `httpErrorHandler`.
It can also be used in combination with validator as a prior step to normalize the
event body input as an object so that the content can be validated.
If the body has been parsed as JSON, you can access the original body (e.g. for webhook signature validation) through the `request.event.rawBody`.
## Install
To install this middleware you can use NPM:
```bash
npm install --save @middy/http-json-body-parser
```
## Options
- `reviver` (function) (default `undefined`): A [reviver](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse#Parameters) parameter may be passed which will be used `JSON.parse`ing the body.
## Sample usage
```javascript
import middy from '@middy/core'
import httpHeaderNormalizer from '@middy/http-header-normalizer'
import httpJsonBodyParser from '@middy/http-json-body-parser'
const handler = middy((event, context) => {
return {}
})
handler
.use(httpHeaderNormalizer())
.use(httpJsonBodyParser())
// invokes the handler
const event = {
headers: {
'Content-Type': 'application/json' // It is important that the request has the proper content type.
},
body: JSON.stringify({foo: 'bar'})
}
handler(event, {}, (_, body) => {
t.is(body,{foo: 'bar'})
})
```
## Middy documentation and examples
For more documentation and examples, refers to the main [Middy monorepo on GitHub](https://github.com/middyjs/middy) or [Middy official website](https://middy.js.org).
## Contributing
Everyone is very welcome to contribute to this repository. Feel free to [raise issues](https://github.com/middyjs/middy/issues) or to [submit Pull Requests](https://github.com/middyjs/middy/pulls).
## License

@@ -103,0 +41,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc