koa deprecated Support for generators will been removed in v3. See the documentation for examples of how to convert old middleware https://github.com/koajs/koa/...,求解?
PHP中文网2017-04-17 15:24:30
找到方法了
npm install koa-convert --save
import convert from 'koa-convert'
app.use(convert(require('koa-static')(__dirname + '/public')));
PHPz2017-04-17 15:24:30
Look here!
This prompt appears because you are still using the traditional generator syntax in 1. So if you still want to use generator syntax, just use the co module!
Official chestnut:
app.use(co.wrap(function *(ctx, next) {
const start = new Date();
yield next();
const ms = new Date() - start;
console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
}));
PS: Since you are already using v2, why not async
/ await
use it!