Package Exports
- loopback-context
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (loopback-context) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
loopback-context
Current context for LoopBack applications, based on node-continuation-local-storage.
WARNING
The module node-continuation-local-storage is known to have many problems, see e.g. issue #59. As a result, loopback-context does not work in many situations, as can be seen from issues reported in LoopBack's issue tracker.
We recommend AGAINST using this module.
If you are running on Node v6, you can try the new alternative cls-hooked.
Usage
- Add
per-requestmiddleware to yourserver/middleware-config.json:
{
"initial": {
"loopback-context#per-request": {
}
}
}- Then you can access the context from your code:
var LoopBackContext = require('loopback-context');
// ...
MyModel.myMethod = function(cb) {
var ctx = LoopBackContext.getCurrentContext();
ctx.get('key');
ctx.set('key', { foo: 'bar' });
});See the official LoopBack documentation for more details.