random jshinting expedition

v1.18.x
psychobunny 11 years ago
parent f0dfee5402
commit 6820e9e662

@ -80,7 +80,7 @@ if (!nconf.get('help') && !nconf.get('setup') && !nconf.get('install') && !nconf
reset();
} else {
displayHelp();
};
}
function loadConfig() {
nconf.file({
@ -156,7 +156,7 @@ function start() {
winston.warn('Your NodeBB schema is out-of-date. Please run the following command to bring your dataset up to spec:');
winston.warn(' node app --upgrade');
winston.warn('To ignore this error (not recommended):');
winston.warn(' node app --no-check-schema')
winston.warn(' node app --no-check-schema');
process.exit();
}
});

@ -1,3 +1,5 @@
"use strict";
var categoriesController = {},
async = require('async'),
qs = require('querystring'),
@ -154,7 +156,7 @@ categoriesController.get = function(req, res, next) {
next(null, {
header: null,
topics: categoryData
})
});
}
], function (err, data) {
if (err) {
@ -185,13 +187,6 @@ categoriesController.get = function(req, res, next) {
}
res.render('category', data.topics);
/*translator.translate(templates['noscript/category'].parse(data.topics), function(translatedHTML) {
res.send(
data.header +
'\n\t<noscript>\n' + templates['noscript/header'] + translatedHTML + '\n\t</noscript>' +
'\n\t' + app.create_route('category/' + category_url) + templates.footer
);
});*/
});
};

@ -1,3 +1,5 @@
"use strict";
var fs = require('fs'),
path = require('path'),
async = require('async'),
@ -102,8 +104,9 @@ var fs = require('fs'),
if (fs.existsSync(config)) {
fs.readFile(config, function (err, file) {
if (err) return next();
else {
if (err) {
return next();
} else {
var configObj = JSON.parse(file.toString());
next(err, configObj);
}
@ -212,7 +215,7 @@ var fs = require('fs'),
if (subpage) {
translator.translate('[[pages:user.' + subpage + ', ' + username + ']]', function(translated) {
callback(null, translated);
})
});
} else {
callback(null, username);
}
@ -271,7 +274,9 @@ var fs = require('fs'),
}
});
Meta.js.scripts = jsPaths.filter(function(path) { return path !== null });
Meta.js.scripts = jsPaths.filter(function(path) {
return path !== null;
});
if (process.env.NODE_ENV !== 'development') {
callback(null, [

@ -1,3 +1,5 @@
"use strict";
var templates = require('./../../public/src/templates'),
translator = require('./../../public/src/translator'),
meta = require('./../meta'),
@ -7,7 +9,7 @@ var templates = require('./../../public/src/templates'),
path = require('path'),
fs = require('fs'),
nconf = require('nconf'),
express = require('express')
express = require('express'),
winston = require('winston');

@ -1,5 +1,18 @@
"use strict";
var app,
middleware = {};
clientScripts,
middleware = {},
async = require('async'),
path = require('path'),
validator = require('validator'),
fs = require('fs'),
nconf = require('nconf'),
plugins = require('./../plugins'),
meta = require('./../meta'),
translator = require('./../../public/src/translator'),
user = require('./../user');
middleware.prepareAPI = function(req, res, next) {
res.locals.isAPI = true;
@ -216,7 +229,7 @@ middleware.build_header = function (options, callback) {
callback(null, template);
});*/
app.render('header', templateValues, function(err, template) {
callback(null, template)
callback(null, template);
});
});
});
@ -238,11 +251,11 @@ middleware.processRender = function(req, res, next) {
self.send(str);
};
if ('function' == typeof options) {
if ('function' === typeof options) {
fn = options, options = {};
}
if ('function' != typeof fn) {
if ('function' !== typeof fn) {
fn = defaultFn;
}
@ -276,9 +289,23 @@ middleware.routeTouchIcon = function(req, res) {
maxAge: app.enabled('cache') ? 5184000000 : 0
});
}
}
};
module.exports = function(webserver) {
app = webserver;
plugins.ready(function() {
// Minify client-side libraries
meta.js.get(function (err, scripts) {
clientScripts = scripts.map(function (script) {
script = {
script: script
};
return script;
});
});
});
return middleware;
}
};

@ -1,4 +1,6 @@
(function(Auth) {
"use strict";
var passport = require('passport'),
passportLocal = require('passport-local').Strategy,
nconf = require('nconf'),
@ -26,16 +28,16 @@
Auth.initialize = function(app) {
app.use(passport.initialize());
app.use(passport.session());
}
};
Auth.get_login_strategies = function() {
return login_strategies;
}
};
Auth.registerApp = function(app) {
Auth.app = app;
}
};
Auth.createRoutes = function(app) {
app.namespace(nconf.get('relative_path'), function () {
@ -49,10 +51,11 @@
req.logout();
}
res.send(200)
res.send(200);
});
for (var i in login_strategies) {
if (login_strategies.hasOwnProperty(i)) {
var strategy = login_strategies[i];
app.get(strategy.url, passport.authenticate(strategy.name, {
scope: strategy.scope
@ -63,13 +66,14 @@
failureRedirect: '/login'
}));
}
}
app.get('/reset/:code', function(req, res) {
app.build_header({
req: req,
res: res
}, function(err, header) {
res.send(header + app.create_route('reset/' + req.params.code) + templates['footer']);
res.send(header + app.create_route('reset/' + req.params.code) + templates.footer);
});
});
@ -78,7 +82,7 @@
req: req,
res: res
}, function(err, header) {
res.send(header + app.create_route('reset') + templates['footer']);
res.send(header + app.create_route('reset') + templates.footer);
});
});
@ -127,10 +131,11 @@
require('../socket.io').emitUserCount();
if(req.body.referrer)
if(req.body.referrer) {
res.redirect(req.body.referrer);
else
} else {
res.redirect(nconf.get('relative_path') + '/');
}
});
} else {
res.redirect(nconf.get('relative_path') + '/register');
@ -138,7 +143,7 @@
});
});
});
}
};
Auth.login = function(username, password, next) {
if (!username || !password) {
@ -186,7 +191,7 @@
});
});
});
}
};
passport.use(new passportLocal(Auth.login));

@ -1,5 +1,8 @@
"use strict";
var nconf = require('nconf'),
controllers = require('./../controllers'),
meta = require('./../meta'),
middleware = {},
/*temp*/
@ -152,7 +155,7 @@ module.exports = function(app, middleware) {
req: req,
res: res
}, function (err, header) {
res.send(header + app.create_route('search/' + req.params.term, null, 'search') + templates.footer);
//res.send(header + app.create_route('search/' + req.params.term, null, 'search') + templates.footer);
});
});
@ -178,8 +181,10 @@ module.exports = function(app, middleware) {
plugins.ready(function() {
plugins.fireHook('filter:server.create_routes', custom_routes, function(err, custom_routes) {
var routes = custom_routes.routes;
for (var route in routes) {
var route,
routes = custom_routes.routes;
for (route in routes) {
if (routes.hasOwnProperty(route)) {
(function(route) {
app[routes[route].method || 'get'](routes[route].route, function(req, res) {
@ -188,7 +193,7 @@ module.exports = function(app, middleware) {
req: options.req || req,
res: options.res || res
}, function (err, header) {
res.send(header + options.content + templates.footer);
//res.send(header + options.content + templates.footer);
});
});
});
@ -197,7 +202,7 @@ module.exports = function(app, middleware) {
}
var apiRoutes = custom_routes.api;
for (var route in apiRoutes) {
for (route in apiRoutes) {
if (apiRoutes.hasOwnProperty(route)) {
(function(route) {
app[apiRoutes[route].method || 'get']('/api' + apiRoutes[route].route, function(req, res) {
@ -210,7 +215,7 @@ module.exports = function(app, middleware) {
}
var templateRoutes = custom_routes.templates;
for (var route in templateRoutes) {
for (route in templateRoutes) {
if (templateRoutes.hasOwnProperty(route)) {
(function(route) {
app.get('/templates/' + templateRoutes[route].template, function(req, res) {
@ -223,4 +228,4 @@ module.exports = function(app, middleware) {
});
});
});
}
};

@ -40,21 +40,7 @@ if(nconf.get('ssl')) {
(function (app) {
"use strict";
var clientScripts,
port = nconf.get('PORT') || nconf.get('port');
plugins.ready(function() {
// Minify client-side libraries
meta.js.get(function (err, scripts) {
clientScripts = scripts.map(function (script) {
script = {
script: script
};
return script;
});
});
});
var port = nconf.get('PORT') || nconf.get('port');
logger.init(app);
auth.registerApp(app);
@ -97,12 +83,12 @@ if(nconf.get('ssl')) {
});
}
if (port != 80 && port != 443 && nconf.get('use_port') === false) {
if (port !== 80 && port !== 443 && nconf.get('use_port') === false) {
winston.info('Enabling \'trust proxy\'');
app.enable('trust proxy');
}
if ((port == 80 || port == 443) && process.env.NODE_ENV !== 'development') {
if ((port === 80 || port === 443) && process.env.NODE_ENV !== 'development') {
winston.info('Using ports 80 and 443 is not recommend; use a proxy instead. See README.md');
}

Loading…
Cancel
Save