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

相关文章
相关标签/搜索