skonves / express-http-context

Get and set request-scoped context anywhere
MIT License
300 stars 26 forks source link

Is there a way to access a CLS namespace from another file? #40

Closed csp197 closed 5 years ago

csp197 commented 5 years ago

I was reading over node-request-context's README and I saw the getNamespace function which allows accessing a namespace set in one file to be accessed from another file.

Is there such a functionality in this package?

rohitsud commented 5 years ago

Yes, this namespace can be accessed from any other file (a module running in the same NodeJS process).

csp197 commented 5 years ago

Gotcha 👍

I wanted to ask if there a more elegant way than declaring the cls namespace variable

var ns = require('express-http-context').ns;