Koa2 的安裝運行記錄(二)

參考 :koa2-boilerplate    https://github.com/superalsrk/koa2-boilerplatenode

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

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

 

一、rkusa/koa-passport    https://github.com/rkusa/koa-passportnpm

 

 

2、Logging 中間件:app

1)(推薦) concurrency-logger - logging requests concurrently and in contextdom

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

 

2)、    koa-logger - development style logger    async

安裝:npm install koa-logger --save-dev
代碼中增長:
var logger = require('koa-logger') app.use(logger())

 功能相似下列函數:ide

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

相關文章
相關標籤/搜索