mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-05-05 14:47:12 -04:00
server.js: use jshint
This commit is contained in:
parent
11746d974b
commit
224e82d8b0
1 changed files with 92 additions and 89 deletions
|
@ -53,10 +53,10 @@ try
|
||||||
}
|
}
|
||||||
catch(e)
|
catch(e)
|
||||||
{
|
{
|
||||||
console.warn("Can't get git version for server header\n" + e.message)
|
console.warn("Can't get git version for server header\n" + e.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("Report bugs at https://github.com/Pita/etherpad-lite/issues")
|
console.log("Report bugs at https://github.com/Pita/etherpad-lite/issues");
|
||||||
|
|
||||||
var serverName = "Etherpad-Lite " + version + " (http://j.mp/ep-lite)";
|
var serverName = "Etherpad-Lite " + version + " (http://j.mp/ep-lite)";
|
||||||
|
|
||||||
|
@ -93,12 +93,15 @@ async.waterfall([
|
||||||
app.configure(function()
|
app.configure(function()
|
||||||
{
|
{
|
||||||
// Activate http basic auth if it has been defined in settings.json
|
// Activate http basic auth if it has been defined in settings.json
|
||||||
if(settings.httpAuth != null) app.use(basic_auth);
|
if(settings.httpAuth) {
|
||||||
|
app.use(basic_auth);
|
||||||
|
}
|
||||||
|
|
||||||
// If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158.
|
// If the log level specified in the config file is WARN or ERROR the application server never starts listening to requests as reported in issue #158.
|
||||||
// Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway.
|
// Not installing the log4js connect logger when the log level has a higher severity than INFO since it would not log at that level anyway.
|
||||||
if (!(settings.loglevel === "WARN" || settings.loglevel == "ERROR"))
|
if (!(settings.loglevel === "WARN" || settings.loglevel == "ERROR")) {
|
||||||
app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.INFO, format: ':status, :method :url'}));
|
app.use(log4js.connectLogger(httpLogger, { level: log4js.levels.INFO, format: ':status, :method :url'}));
|
||||||
|
}
|
||||||
app.use(express.cookieParser());
|
app.use(express.cookieParser());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -137,6 +140,7 @@ async.waterfall([
|
||||||
//checks for padAccess
|
//checks for padAccess
|
||||||
function hasPadAccess(req, res, callback)
|
function hasPadAccess(req, res, callback)
|
||||||
{
|
{
|
||||||
|
console.log(req.params);
|
||||||
securityManager.checkAccess(req.params.pad, req.cookies.sessionid, req.cookies.token, req.cookies.password, function(err, accessObj)
|
securityManager.checkAccess(req.params.pad, req.cookies.sessionid, req.cookies.token, req.cookies.password, function(err, accessObj)
|
||||||
{
|
{
|
||||||
if(ERR(err, callback)) return;
|
if(ERR(err, callback)) return;
|
||||||
|
@ -203,7 +207,7 @@ async.waterfall([
|
||||||
function(callback)
|
function(callback)
|
||||||
{
|
{
|
||||||
//return if the there is no padId
|
//return if the there is no padId
|
||||||
if(padId == null)
|
if(!padId)
|
||||||
{
|
{
|
||||||
callback("notfound");
|
callback("notfound");
|
||||||
return;
|
return;
|
||||||
|
@ -282,8 +286,7 @@ async.waterfall([
|
||||||
}
|
}
|
||||||
|
|
||||||
//if abiword is disabled, and this is a format we only support with abiword, output a message
|
//if abiword is disabled, and this is a format we only support with abiword, output a message
|
||||||
if(settings.abiword == null &&
|
if(!settings.abiword && ["odt", "pdf", "doc"].indexOf(req.params.type) !== -1)
|
||||||
["odt", "pdf", "doc"].indexOf(req.params.type) !== -1)
|
|
||||||
{
|
{
|
||||||
res.send("Abiword is not enabled at this Etherpad Lite instance. Set the path to Abiword in settings.json to enable this feature");
|
res.send("Abiword is not enabled at this Etherpad Lite instance. Set the path to Abiword in settings.json to enable this feature");
|
||||||
return;
|
return;
|
||||||
|
@ -309,7 +312,7 @@ async.waterfall([
|
||||||
}
|
}
|
||||||
|
|
||||||
//if abiword is disabled, skip handling this request
|
//if abiword is disabled, skip handling this request
|
||||||
if(settings.abiword == null)
|
if(!settings.abiword)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
return;
|
return;
|
||||||
|
@ -344,16 +347,16 @@ async.waterfall([
|
||||||
response = req.query.jsonp + "(" + response + ")";
|
response = req.query.jsonp + "(" + response + ")";
|
||||||
|
|
||||||
res._send(response);
|
res._send(response);
|
||||||
}
|
};
|
||||||
|
|
||||||
//call the api handler
|
//call the api handler
|
||||||
apiHandler.handle(req.params.func, fields, req, res);
|
apiHandler.handle(req.params.func, fields, req, res);
|
||||||
}
|
};
|
||||||
|
|
||||||
//This is a api GET call, collect all post informations and pass it to the apiHandler
|
//This is a api GET call, collect all post informations and pass it to the apiHandler
|
||||||
app.get('/api/1/:func', function(req, res)
|
app.get('/api/1/:func', function(req, res)
|
||||||
{
|
{
|
||||||
apiCaller(req, res, req.query)
|
apiCaller(req, res, req.query);
|
||||||
});
|
});
|
||||||
|
|
||||||
//This is a api POST call, collect all post informations and pass it to the apiHandler
|
//This is a api POST call, collect all post informations and pass it to the apiHandler
|
||||||
|
@ -361,7 +364,7 @@ async.waterfall([
|
||||||
{
|
{
|
||||||
new formidable.IncomingForm().parse(req, function(err, fields, files)
|
new formidable.IncomingForm().parse(req, function(err, fields, files)
|
||||||
{
|
{
|
||||||
apiCaller(req, res, fields)
|
apiCaller(req, res, fields);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -453,7 +456,7 @@ async.waterfall([
|
||||||
setTimeout(function(){
|
setTimeout(function(){
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}, 3000);
|
}, 3000);
|
||||||
}
|
};
|
||||||
|
|
||||||
//connect graceful shutdown with sigint and uncaughtexception
|
//connect graceful shutdown with sigint and uncaughtexception
|
||||||
if(os.type().indexOf("Windows") == -1)
|
if(os.type().indexOf("Windows") == -1)
|
||||||
|
@ -489,7 +492,7 @@ async.waterfall([
|
||||||
error: function (str)
|
error: function (str)
|
||||||
{
|
{
|
||||||
socketIOLogger.error.apply(socketIOLogger, arguments);
|
socketIOLogger.error.apply(socketIOLogger, arguments);
|
||||||
},
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//minify socket.io javascript
|
//minify socket.io javascript
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue