node package manager
Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org ยป



The ot-context package provides support for holding a context object that is bound to e.g. a request scope. This is useful for holding metadata such as a RequestId token or user authorization.

Ideally such context would be passed around explicitly. However, requiring all code and modules that run inside of a request context to be aware of this context mechanism is a monumental problem.

Context Object

The context object is a simple dictionary.

The current context may always be retrieved with the context.current() method. You may create a new context with the context.enter(next) method. You may ensure a context exists with the context.ensure(next) method.

context.middleware is Express middleware that enters a new context for every request, implementing a basic request scope.


npm install --save ot-context