Skip to content

Commit

Permalink
fixup! Use renamed loopback-context, fix deprecation notice
Browse files Browse the repository at this point in the history
  • Loading branch information
bajtos committed Jul 29, 2016
1 parent e1b252e commit ba55e26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 21 deletions.
30 changes: 15 additions & 15 deletions lib/current-context.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

var juggler = require('loopback-datasource-juggler');
var remoting = require('strong-remoting');
var ClsContext = require('loopback-context-cls');
var LoopBackContext = require('loopback-context');
var deprecated = require('depd')('loopback');

module.exports = function(loopback) {
Expand All @@ -17,13 +17,13 @@ module.exports = function(loopback) {
* @returns {ChainedContext} The context object or null.
*/
loopback.getCurrentContext = function() {
// NOTE(bajtos) ClsContext.getCurrentContext is overriden whenever
// NOTE(bajtos) LoopBackContext.getCurrentContext is overriden whenever
// the context changes, therefore we cannot simply assign
// ClsContext.getCurrentContext() to loopback.getCurrentContext()
deprecated('loopback.getCurrentContext() is deprecated. ' +
'Consider using different means of passing the context around. ' +
'As a short-term fix, use loopback-context-cls module.');
return ClsContext.getCurrentContext();
// LoopBackContext.getCurrentContext() to loopback.getCurrentContext()
deprecated('loopback.getCurrentContext() is deprecated. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
return LoopBackContext.getCurrentContext();
};

juggler.getCurrentContext =
Expand All @@ -45,10 +45,10 @@ module.exports = function(loopback) {
* When no value is provided, then the default global context is used.
*/
loopback.runInContext = function(fn) {
deprecated('loopback.runInContext() is deprecated. ' +
'Consider using different means of passing the context around. ' +
'As a short-term fix, use loopback-context-cls module.');
return ClsContext.runInContext(fn);
deprecated('loopback.runInContext() is deprecated. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
return LoopBackContext.runInContext(fn);
};

/**
Expand All @@ -69,9 +69,9 @@ module.exports = function(loopback) {
* @return {ChainedContext} The new context object.
*/
loopback.createContext = function(scopeName) {
deprecated('loopback.createContext() is deprecated. ' +
'Consider using different means of passing the context around. ' +
'As a short-term fix, use loopback-context-cls module.');
return ClsContext.createContext(scopeName);
deprecated('loopback.createContext() is deprecated. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
return LoopBackContext.createContext(scopeName);
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"express": "^4.12.2",
"inflection": "^1.6.0",
"loopback-connector-remote": "^1.0.3",
"loopback-context-cls": "^1.0.0-1",
"loopback-context": "^1.0.0",
"loopback-phase": "^1.2.0",
"nodemailer": "^1.3.1",
"nodemailer-stub-transport": "^0.1.5",
Expand Down
10 changes: 5 additions & 5 deletions server/middleware/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// License text available at https://opensource.org/licenses/MIT

var deprecated = require('depd')('loopback');
var m = require('loopback-context-cls/server/middleware/per-request-context');
var impl = require('loopback-context/server/middleware/per-request-context');

module.exports = function() {
deprecated('loopback#context middleware is deprecated. ' +
'Consider using different means of passing the context around. ' +
'As a short-term fix, use loopback-context-cls module.');
return m.apply(this, arguments);
deprecated('loopback#context middleware is deprecated. See ' +
'https://docs.strongloop.com/display/APIC/Using%20current%20context ' +
'for more details.');
return impl.apply(this, arguments);
};

0 comments on commit ba55e26

Please sign in to comment.