Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

koa-router@7 supports generator middleware for compatibility #468

Open
hardfist opened this issue Jul 4, 2018 · 0 comments
Open

koa-router@7 supports generator middleware for compatibility #468

hardfist opened this issue Jul 4, 2018 · 0 comments

Comments

@hardfist
Copy link

hardfist commented Jul 4, 2018

node.js version: 8.9.4

npm/yarn and version:

koa-router version: 7.4.0

koa version: 2.5.1

Code sample:

var Koa = require('koa');
var Router = require('koa-router');
var Boom = require('boom');

var app = new Koa();
var router = new Router();
router.get('/demo',function*(next){
   this.body = 'this is a test';
   yield next;
 // not working
});

app.use(router.routes());
app.use(router.allowedMethods({
  throw: true,
  notImplemented: () => new Boom.notImplemented(),
  methodNotAllowed: () => new Boom.methodNotAllowed()
}));

Expected Behavior:

supports generator

I recently update koa@1 to koa@2,since koa@2 supports generator koa@1 for compatiable,I can migrate my app progressively and don't need to update all my generator to async/await middleware,
but koa-router@2 doesn't support generator yet which makes migrations hard。So like koa2 I think if koa-router@2 also supports generator middleware It will be very convenient for migration. I make an pr #467 to support generator. Thanks.

Actual Behavior:

not supports generator

Additional steps, HTTP request details, or to reproduce the behavior or a test case:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant