Merge pull request #4787 from akhoury/rm-cls

rm cls because it's not ready yet
v1.18.x
Barış Soner Uşaklı 9 years ago committed by GitHub
commit 4854f78afa

@ -22,7 +22,6 @@
var nconf = require('nconf');
nconf.argv().env('__');
require('continuation-local-storage');
var url = require('url'),
async = require('async'),

@ -26,7 +26,6 @@
"connect-mongo": "~1.1.0",
"connect-multiparty": "^2.0.0",
"connect-redis": "~3.0.2",
"continuation-local-storage": "^3.1.6",
"cookie-parser": "^1.3.3",
"cron": "^1.0.5",
"csurf": "^1.6.1",

@ -1,38 +0,0 @@
var path = require('path');
var sockets = require('path');
var websockets = require('../socket.io/');
var continuationLocalStorage = require('continuation-local-storage');
var APP_NAMESPACE = require(path.join(__dirname, '../../package.json')).name;
var namespace = continuationLocalStorage.createNamespace(APP_NAMESPACE);
(function(cls) {
cls.http = function (req, res, next) {
namespace.run(function() {
namespace.set('request', req);
next && next();
});
};
cls.socket = function (socket, payload, event, next) {
namespace.run(function() {
namespace.set('request', websockets.reqFromSocket(socket, payload, event));
next && next();
});
};
cls.get = function (key) {
return namespace.get(key);
};
cls.set = function (key, value) {
return namespace.set(key, value);
};
cls.setItem = cls.set;
cls.getItem = cls.get;
cls.namespace = namespace;
cls.continuationLocalStorage = continuationLocalStorage;
})(exports);

@ -14,7 +14,6 @@ var meta = require('../meta'),
compression = require('compression'),
favicon = require('serve-favicon'),
session = require('express-session'),
cls = require('./cls'),
useragent = require('express-useragent');
@ -62,7 +61,7 @@ module.exports = function(app) {
if (nconf.get('secure')) {
cookie.secure = true;
}
if (relativePath !== '') {
cookie.path = relativePath;
}
@ -78,7 +77,6 @@ module.exports = function(app) {
app.use(middleware.addHeaders);
app.use(middleware.processRender);
app.use(cls.http);
auth.initialize(app, middleware);
return middleware;

@ -7,29 +7,6 @@ module.exports = function(Plugins) {
Plugins.deprecatedHooks = {
'filter:user.custom_fields': null // remove in v1.1.0
};
Plugins.deprecatedHooksParams = {
'action:homepage.get': '{req, res}',
'filter:register.check': '{req, res}',
'action:user.loggedOut': '{req, res}',
'static:user.loggedOut': '{req, res}',
'filter:categories.build': '{req, res}',
'filter:category.build': '{req, res}',
'filter:group.build': '{req, res}',
'filter:register.build': '{req, res}',
'filter:composer.build': '{req, res}',
'filter:popular.build': '{req, res}',
'filter:recent.build': '{req, res}',
'filter:topic.build': '{req, res}',
'filter:users.build': '{req, res}',
'filter:admin.category.get': '{req, res}',
'filter:middleware.renderHeader': '{req, res}',
'filter:widget.render': '{req, res}',
'filter:middleware.buildHeader': '{req, locals}',
'action:middleware.pageView': '{req}',
'action:meta.override404': '{req}'
};
/*
`data` is an object consisting of (* is required):
`data.hook`*, the name of the NodeBB hook
@ -62,12 +39,6 @@ module.exports = function(Plugins) {
parts.pop();
}
var hook = parts.join(':');
if (Plugins.deprecatedHooksParams[hook]) {
winston.warn('[plugins/' + id + '] Hook `' + hook + '` parameters: `' + Plugins.deprecatedHooksParams[hook] + '`, are being deprecated, '
+ 'all plugins should now use the `middleware/cls` module instead of hook\'s arguments to get a reference to the `http-request` or the `socket-request` object(s) (from which you can get the current `uid` if you need to.) '
+ '- for more info, visit https://docs.nodebb.org/en/latest/plugins/create.html#getting-a-reference-to-each-request-from-within-any-plugin-hook\n');
delete Plugins.deprecatedHooksParams[hook];
}
}
if (data.hook && data.method) {

@ -11,7 +11,6 @@ var url = require('url');
var db = require('../database');
var logger = require('../logger');
var ratelimit = require('../middleware/ratelimit');
var cls = require('../middleware/cls');
(function(Sockets) {
var Namespaces = {};
@ -30,7 +29,6 @@ var cls = require('../middleware/cls');
io.use(authorize);
io.on('connection', onConnection);
io.on('disconnect', onDisconnect);
io.listen(server, {
transports: nconf.get('socket.io:transports')
@ -44,14 +42,10 @@ var cls = require('../middleware/cls');
logger.io_one(socket, socket.uid);
cls.socket(socket, null, 'connection', function () {
onConnect(socket);
});
onConnect(socket);
socket.on('*', function (payload) {
cls.socket(socket, payload, null, function () {
onMessage(socket, payload);
});
onMessage(socket, payload);
});
}
@ -64,12 +58,6 @@ var cls = require('../middleware/cls');
}
}
function onDisconnect(socket) {
cls.socket(socket, null, 'disconnect', function () {
});
}
function onMessage(socket, payload) {
if (!payload.data.length) {
return winston.warn('[socket.io] Empty payload');
@ -235,4 +223,4 @@ var cls = require('../middleware/cls');
};
};
})(exports);
})(exports);

Loading…
Cancel
Save