Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

koa

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.

like image 324
DAESEONG KIM Avatar asked Dec 16 '16 02:12

DAESEONG KIM


2 Answers

[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.

like image 117
DAESEONG KIM Avatar answered Nov 08 '22 16:11

DAESEONG KIM


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

like image 26
Nicks Avatar answered Nov 08 '22 18:11

Nicks