koajs / bodyparser

Koa body parsing middleware
MIT License
1.31k stars 116 forks source link

Implement with plain Promises instead of async-await #63

Closed jeffijoe closed 7 years ago

jeffijoe commented 7 years ago

I love async-await, but this module now requires me to update to node 7.6 which still isn't very supported by some modules like bcrypt.

I know this isn't koa-bodyparser's problem, but Koa 2 itself can run on Node 6 with plain promises while installing (official Koa) middleware requires 7.6 which feels like a disconnect.

Using plain promises shouldn't be too hard in this case and would also inevitably give better performance (micro but it's free) and wider support.

dead-horse commented 7 years ago

I think you can use generator version(2.x) with koa-convert, this branch will be maintained till node 8 released.

I don't think we should use plain promise to write middleware for koa which aim to help people write asynchronous code more easy.

dead-horse commented 7 years ago

also 3.x is using plain promise, but maybe lack of maintenance.

jeffijoe commented 7 years ago

The middleware implementation is just a detail, the problem is not using async-await in your app, but transpiling koa-bodyparser for < Node 7.6

jeffijoe commented 7 years ago

And I think for a middleware that is used as much and as often as a bodyparser, it would make sense to squeeze as much perf out of the runtime as possible.