what's the difference between koa-body vs koa-bodyparser?
Asked Answered
A

2

15

I'm developing node server using koa.js

I have looked for some libraries for body parser.

And there are several kinds of koa body parser.

But I don't know what differences btw them including koa-body and koa-bodyparser.

Can you explain it?

Thank you in advance.

Akerley answered 16/12, 2016 at 2:15 Comment(0)
A
17

[New answer]

koa-body now support koa version 2. The main difference now remains about file payload parsing. The koa-bodyparser cannot parse files, i.e. multipart/form-data.

[Old answer]

Oh, I got it.

https://github.com/koajs/koa/wiki

koa-body supports koa v1, koa-bodyparser supports koa v2.

And former can parse file, but later can't.

Thanks.

Akerley answered 16/12, 2016 at 2:29 Comment(3)
koa-body does support Koa v2, you just have to get the right branch by doing npm install koa-body@next. I've edited the wiki to prevent any confusion for other people.Denizen
@DAESONG KIM latter* :DSurveillance
@saadq are the two branches merged now? I can only see one repository on the wiki.Dogmatize
B
3

Both are Koa body parser middleware. I recently faced an issue where I wanted to handle file upload and there comes the main difference.

Koa-body supports -- koa, urlencoded, multipart, json, body, parser, form and

koa-bodyparser supports -- json, urlencoded, koa, body.

So if you are looking for file uploading features , go ahead with koa-body or koa-better-body (which has more wider scopes)

Here is detailed reference

Baseburner answered 30/4, 2021 at 0:42 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.