koa-get-body
A body parser for koa2, support urlencoded
, multipart
, json
,text
and xml
(need option xmlParser
configured).
(return raw body for non-supported mime types)
Installation
npm install koa-get-body
Usage
const Koa = const getBody = let app = appapp
Custom Options
appapp
Options
- alias - {string}, append an alias to koa
ctx
, then you can usectx.aliasName()
- jsonTypes - {array|string}, types to detect as
json
, see type-is, default:['json', '+json']
, the following mime types will matched:application/json
,application/vnd.api+json
,application/json-patch+json
- textTypes - {array|string}, types to detect as
text
, default:text/*
- xmlTypes - {array|string}, types to detect as
xml
, default:xml
- xmlParser - {function}, a function to parse xml if you needed
- uploadDir - {string}, custom upload dir, default to
os.tmpdir()
- getFileName - {function}, generate upload temp filename in you own way
- more options: see Busboy options
TODO
- add support for array or object fieldNames (
[]
or[name]
)
License
MIT