node package manager
Loosely couple your services. Use Orgs to version and reuse your code. Create a free org ยป

ot-context

ot-context-nodejs

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.

Installation

npm install --save ot-context