koa-mongo-rest
koa-mongo-rest copied to clipboard
incompatible with koabodyparser
when I add app.use(bodyParser) all the methods in koa-mongo-rest which look for the body start failing silently and the request is left hanging.
I'm not sure how to deal with that yet, so I'm opening for discussion.
koa-mongo-rest uses co-body, so maybe you ran into some conflict there, if bodyParsers modified request in a way that makes it unreadable to co-body.
RIght, so one way to fix this would be to add koabodyparser as a dependency to koa-mongo-rest instead of parsing the body in it, that way both can work, otherwise i'm not sure how to make them compatible
For myself, I don't care if body is parsed in koa-mongo-rest by co-body or koabodyparser. You can give it a try. But it has to work even if my application does not use koabodyparser.
I tried koa-body-parser as well, and it does not work for me for some reason. However, it's extremely simple module. I ended up writing my own body parsing middleware based on it, it looks like this and works with koa-mongo rest:
app.use(function *(next) {
const encoding = 'transfer-encoding' in this.req.headers;
if (encoding || this.request.length) {
this.request.body = yield parse(this, {
limit: '1kb'
});
}
yield next;
});
Fixed in 0.3.4, please use my fork: https://github.com/tomaash/koa-body-parser
This could probably be resolved?