From a7d9e6b9a39132c6fe8a628d77e7d47a1b42f7de Mon Sep 17 00:00:00 2001 From: Montana Scott Rowe Date: Thu, 19 Jan 2012 17:36:56 -0600 Subject: [PATCH] checked to make sure init is passed a function --- node/server.js | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/node/server.js b/node/server.js index aa6e52fa6..db8e72995 100644 --- a/node/server.js +++ b/node/server.js @@ -451,6 +451,8 @@ function gotoPadCombinator(checkPadName, padManager){ } function init(additionalSetup){ + if("function" != typeof additionalSetup) + additionalSetup = function(){}; async.waterfall([ //initalize the database setupDb, @@ -485,6 +487,7 @@ function init(additionalSetup){ var httpLogger = log4js.getLogger("http"); var apiLogger = log4js.getLogger("API"); + //checks for padAccess function hasPadAccess(req, res, callback) { @@ -561,27 +564,28 @@ function init(additionalSetup){ }; var posts = { - - //handle import requests - '/p/:pad/import': postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler) - //This is a api POST call, collect all post informations and pass it to the apiHandler - '/api/1/:func': function(req, res) - { - new formidable.IncomingForm().parse(req, function(err, fields, files) - { - apiCaller(req, res, fields) - }); - }, - - //The Etherpad client side sends information about how a disconnect happen - '/ep/pad/connection-diagnostic-info': logOkPostCombinator("DIAGNOSTIC-INFO", "log", "diagnosticInfo"), - - //The Etherpad client side sends information about client side javscript errors - '/jserror': logOkPostCombinator("CLIENT SIDE JAVASCRIPT ERROR", "error", "errorInfo") + '/p/:pad/import': postImportPadCombinator( + goToPad, settings, serverName, hasPadAccess, importHandler + ), + '/api/1/:func': function(req, res){ + new formidable.IncomingForm().parse( + req, + function(err, fields, files) + { + apiCaller(req, res, fields) + }); + }, + '/ep/pad/connection-diagnostic-info': logOkPostCombinator( + "DIAGNOSTIC-INFO", "log", "diagnosticInfo" + ), + '/jserror': logOkPostCombinator( + "CLIENT SIDE JAVASCRIPT ERROR", "error", "errorInfo" + ) }; - + + - additionalSetup(app, gets, posts); + additionalSetup(app, gets, posts, managers, handlers, db); for(var key in gets) app.get(key, gets[key]); @@ -602,4 +606,4 @@ function init(additionalSetup){ } this.init = init; -init(function(app, gets, posts){}); \ No newline at end of file +init(function(app, gets, posts, managers, handlers, db){}); \ No newline at end of file