1.0.2 • Published 9 years ago

koa-continuation-local-storage v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
9 years ago

koa-continuation-local-storage Build Status

continuation-local-storage middleware for koa.

install

Install the package with npm:

$ 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