mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-27 17:16:14 +01:00
feat: give names to middlewares
This commit is contained in:
@@ -52,7 +52,7 @@ middleware.stripLeadingSlashes = function (req, res, next) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.pageView = function (req, res, next) {
|
middleware.pageView = function pageView(req, res, next) {
|
||||||
analytics.pageView({
|
analytics.pageView({
|
||||||
ip: req.ip,
|
ip: req.ip,
|
||||||
uid: req.uid,
|
uid: req.uid,
|
||||||
@@ -74,7 +74,7 @@ middleware.pageView = function (req, res, next) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
middleware.pluginHooks = function (req, res, next) {
|
middleware.pluginHooks = function pluginHooks(req, res, next) {
|
||||||
async.each(plugins.loadedHooks['filter:router.page'] || [], function (hookObj, next) {
|
async.each(plugins.loadedHooks['filter:router.page'] || [], function (hookObj, next) {
|
||||||
hookObj.method(req, res, next);
|
hookObj.method(req, res, next);
|
||||||
}, function (err) {
|
}, function (err) {
|
||||||
@@ -159,7 +159,7 @@ middleware.privateUploads = function (req, res, next) {
|
|||||||
next();
|
next();
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.busyCheck = function (req, res, next) {
|
middleware.busyCheck = function busyCheck(req, res, next) {
|
||||||
if (global.env === 'production' && meta.config.eventLoopCheckEnabled && toobusy()) {
|
if (global.env === 'production' && meta.config.eventLoopCheckEnabled && toobusy()) {
|
||||||
analytics.increment('errors:503');
|
analytics.increment('errors:503');
|
||||||
res.status(503).type('text/html').sendFile(path.join(__dirname, '../../public/503.html'));
|
res.status(503).type('text/html').sendFile(path.join(__dirname, '../../public/503.html'));
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ var meta = require('../meta');
|
|||||||
var user = require('../user');
|
var user = require('../user');
|
||||||
|
|
||||||
module.exports = function (middleware) {
|
module.exports = function (middleware) {
|
||||||
middleware.maintenanceMode = function (req, res, callback) {
|
middleware.maintenanceMode = function maintenanceMode(req, res, callback) {
|
||||||
if (!meta.config.maintenanceMode) {
|
if (!meta.config.maintenanceMode) {
|
||||||
return setImmediate(callback);
|
return setImmediate(callback);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ module.exports = function (middleware) {
|
|||||||
var templateToRender;
|
var templateToRender;
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function (next) {
|
function (next) {
|
||||||
options.loggedIn = !!req.uid;
|
options.loggedIn = req.uid > 0;
|
||||||
options.relative_path = nconf.get('relative_path');
|
options.relative_path = nconf.get('relative_path');
|
||||||
options.template = { name: template };
|
options.template = { name: template };
|
||||||
options.template[template] = true;
|
options.template[template] = true;
|
||||||
|
|||||||
@@ -129,7 +129,7 @@ module.exports = function (middleware) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
middleware.redirectToAccountIfLoggedIn = function (req, res, next) {
|
middleware.redirectToAccountIfLoggedIn = function (req, res, next) {
|
||||||
if (req.session.forceLogin || !req.uid) {
|
if (req.session.forceLogin || req.uid <= 0) {
|
||||||
return next();
|
return next();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,7 +233,7 @@ module.exports = function (middleware) {
|
|||||||
res.status(403).render('403', { title: '[[global:403.title]]' });
|
res.status(403).render('403', { title: '[[global:403.title]]' });
|
||||||
};
|
};
|
||||||
|
|
||||||
middleware.registrationComplete = function (req, res, next) {
|
middleware.registrationComplete = function registrationComplete(req, res, next) {
|
||||||
// If the user's session contains registration data, redirect the user to complete registration
|
// If the user's session contains registration data, redirect the user to complete registration
|
||||||
if (!req.session.hasOwnProperty('registration')) {
|
if (!req.session.hasOwnProperty('registration')) {
|
||||||
return setImmediate(next);
|
return setImmediate(next);
|
||||||
@@ -244,7 +244,7 @@ module.exports = function (middleware) {
|
|||||||
|
|
||||||
controllers.helpers.redirect(res, '/register/complete');
|
controllers.helpers.redirect(res, '/register/complete');
|
||||||
} else {
|
} else {
|
||||||
return setImmediate(next);
|
setImmediate(next);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user