mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-02 20:16:04 +01:00
merge
This commit is contained in:
@@ -55,13 +55,16 @@ module.exports.listen = function (callback) {
|
||||
callback = callback || function () { };
|
||||
emailer.registerApp(app);
|
||||
|
||||
setupExpressApp(app);
|
||||
|
||||
helpers.register();
|
||||
|
||||
logger.init(app);
|
||||
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
setupExpressApp(app, next);
|
||||
},
|
||||
function (next) {
|
||||
helpers.register();
|
||||
|
||||
logger.init(app);
|
||||
next();
|
||||
},
|
||||
initializeNodeBB,
|
||||
function (next) {
|
||||
winston.info('NodeBB Ready');
|
||||
@@ -110,7 +113,7 @@ function initializeNodeBB(callback) {
|
||||
});
|
||||
}
|
||||
|
||||
function setupExpressApp(app) {
|
||||
function setupExpressApp(app, callback) {
|
||||
var middleware = require('./middleware');
|
||||
|
||||
var relativePath = nconf.get('relative_path');
|
||||
@@ -158,6 +161,8 @@ function setupExpressApp(app) {
|
||||
var toobusy = require('toobusy-js');
|
||||
toobusy.maxLag(parseInt(meta.config.eventLoopLagThreshold, 10) || 100);
|
||||
toobusy.interval(parseInt(meta.config.eventLoopInterval, 10) || 500);
|
||||
|
||||
setupAutoLocale(app, callback);
|
||||
}
|
||||
|
||||
function ping(req, res) {
|
||||
@@ -195,6 +200,35 @@ function setupCookie() {
|
||||
return cookie;
|
||||
}
|
||||
|
||||
function setupAutoLocale(app, callback) {
|
||||
languages.listCodes(function (err, codes) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
var defaultLang = meta.config.defaultLang || 'en-GB';
|
||||
|
||||
var langs = [defaultLang].concat(codes).filter(function (el, i, arr) {
|
||||
return arr.indexOf(el) === i;
|
||||
});
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
if (parseInt(req.uid, 10) > 0 || parseInt(meta.config.autoDetectLang, 10) !== 1) {
|
||||
return next();
|
||||
}
|
||||
|
||||
var lang = req.acceptsLanguages(langs);
|
||||
if (!lang) {
|
||||
return next();
|
||||
}
|
||||
req.query.lang = lang;
|
||||
next();
|
||||
});
|
||||
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
||||
function listen(callback) {
|
||||
callback = callback || function () { };
|
||||
var port = parseInt(nconf.get('port'), 10);
|
||||
|
||||
Reference in New Issue
Block a user