koa-continuation-local-storage

1.0.2 • Public • Published

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

Dependents (0)

Package Sidebar

Install

npm i koa-continuation-local-storage

Weekly Downloads

5

Version

1.0.2

License

MIT

Last publish

Collaborators

  • lennon