This middleware is written on top of busboy for koa2.x to parse request bodies and async/await
.
It will parse content-types with multipart/form-data
, application/x-www-form-urlencoded
and application/json
.
Install
npm install koa-async-body
Example
'use strict'; const Koa = ;const KoaBody = ; const koaBody = limits: fileSize: 1024*1024*2 files: 1 parts: 1000 //You can find the options in https://github.com/mscdex/busboy uploadDir: '/var/tmp' //customize the upload directory, default use require('os').tmpDir() keyPath: 'foobar' //customize appending to `koa context`, default use `ctx.requestBody`; const app = ; app; app; app;//curl -v -X POST 'http://localhost:3000' --data-urlencode 'hello=world'
Error handling
app;