Skip to content

Current context for LoopBack applications, based on node-continuation-local-storage

Notifications You must be signed in to change notification settings

josieusa/loopback-context

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

loopback-context

Current context for LoopBack applications, based on node-continuation-local-storage.

Usage

  1. Add per-request middleware to your server/middleware-config.json:
{
  "initial": {
    "loopback-context#per-request": {
    }
  }
}
  1. 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 also https://docs.strongloop.com/display/APIC/Using+current+context

About

Current context for LoopBack applications, based on node-continuation-local-storage

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%