Koa2 的安装运行记录(二)

参考 :koa2-boilerplate    https://github.com/superalsrk/koa2-boilerplate

          Ajax Login and Ajax Logout in Koa2, based on koa-passport and passport-local

         https://github.com/koajs/koa/wiki   有中间件列表

 

1、rkusa/koa-passport    https://github.com/rkusa/koa-passport

 

 

二、Logging 中间件:

1)(推荐) concurrency-logger - logging requests concurrently and in context

              https://github.com/PabloSichert/concurrency-logger

 

2)、    koa-logger - development style logger    

安装:npm install koa-logger --save-dev
代码中增加:
var logger = require('koa-logger') app.use(logger())

 功能类似下列函数:

app.use(async (ctx, next) => {
   const start = new Date();
   await next();
   const ms = new Date() - start;
   console.log(`${ctx.method} ${ctx.url} - ${ms}ms`);
});

 

3)(暂不考虑) koa-log4 - a wrapper for log4js-node which supports koa middleware

   

 

posted @ 2016-11-17 14:41  Hopesun  阅读(758)  评论(0编辑  收藏  举报