koa-continuation-local-storage
v1.0.2
Published
Continuation local storage middleware for koa
Downloads
13
Maintainers
Readme
koa-continuation-local-storage
continuation-local-storage
middleware forkoa
.
install
$ npm install koa-continuation-local-storage
usage
import cls from 'koa-continuation-local-storage';
import koa from 'koa';
import { createNamespace } from 'continuation-local-storage';
const ns = createNamespace('ns');
const app = koa();
app
.use(cls({
ns: ns
}))
.use(function* (next) {
ns.set('foo', 'bar');
yield* next;
})
.use(function* () {
this.body = ns.get('foo');
});
api
cls(opts)
Create middleware that wraps downstream middlewares to opts.ns
namespace.
license
MIT