Body parsers extracted from Micro
Built with ❤︎ by tiaanduplessis and contributors
The buffer
, text
and json
body parsers extracted from Micro.
$ npm install micro-parsers
# OR
$ yarn add micro-parsers
Example extracted from from Micro README. See it for more usage examples.
const {buffer, text, json} = require('micro-parsers')
module.exports = async (req, res) => {
const buf = await buffer(req)
console.log(buf)
// <Buffer 7b 22 70 72 69 63 65 22 3a 20 39 2e 39 39 7d>
const txt = await text(req)
// '{"price": 9.99}'
const js = await json(req)
// { price: 9.99 }
console.log(js.price)
return ''
}
Contributions are welcome!
- Fork it.
- Create your feature branch:
git checkout -b my-new-feature
- Commit your changes:
git commit -am 'Add some feature'
- Push to the branch:
git push origin my-new-feature
- Submit a pull request :D
Or open up a issue.
Licensed under the MIT License.