koa-aspect

0.3.0 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i koa-aspect

Weekly Downloads

0

Version

0.3.0

License

MIT

Last publish

Collaborators

  • poying