node package manager
Easy collaboration. Discover, share, and reuse code in your team. Create a free org »

koa-aspect

koa-aspect

Work in process

Build Status Downloads Version

AOP for "Koa-like" modules.

$ npm i --save koa-aspect

Example

var aspect = require('koa-aspect');
var app = koa();
 
app.use(function *mw1(next) { yield* next; });
app.use(function *mw2(next) { yield* next; });
app.use(function *lol(next) { yield* next; });
 
aspect(app, {
  wildcard: /^mw/,
  before: function *() {
    console.log(this.originalUrl);
  }
});
 
app.listen(8080);

API

Join points

  • before
  • afterReturning
  • afterThrowing
  • after
  • around