@middy/http-urlencode-body-parser

Urlencode body parser middleware for the middy framework

Stats

StarsIssuesVersionUpdatedCreatedSize
@middy/http-urlencode-body-parser
2,383192.5.1a month ago3 years agoMinified + gzip package size for @middy/http-urlencode-body-parser in KB

Readme

Middy http-urlencode-body-parser middleware

Middy logo

HTTP URLencode body parser middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

This middleware automatically parses HTTP requests with URL-encoded body (typically the result of a form submit).

Install

To install this middleware you can use NPM:

npm install --save @middy/http-urlencode-body-parser

Sample usage

import middy from '@middy/core'
import httpUrlEncodeBodyParser from '@middy/http-urlencode-body-parser'

const handler = middy((event, context) => {
  return event.body // propagates the body as response
})

handler.use(httpUrlEncodeBodyParser())

// When Lambda runs the handler with a sample event...
const event = {
  headers: {
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: 'frappucino=muffin&goat%5B%5D=scone&pond=moose'
}

handler(event, {}, (_, body) => {
  t.deepEqual(body, {
    frappucino: 'muffin',
    'goat[]': 'scone',
    pond: 'moose'
  })
})

Middy documentation and examples

For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

License

Licensed under MIT License. Copyright (c) 2017-2021 Luciano Mammino, will Farrell, and the Middy team.

FOSSA Status

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.