placed additionalSetup hook

This commit is contained in:
Montana Scott Rowe 2012-01-19 16:55:39 -06:00
parent a45dd74b31
commit 1b03e1991a

View file

@ -450,7 +450,8 @@ function gotoPadCombinator(checkPadName, padManager){
} }
} }
async.waterfall([ function init(additionalSetup){
async.waterfall([
//initalize the database //initalize the database
setupDb, setupDb,
//initalize the http server //initalize the http server
@ -486,6 +487,9 @@ async.waterfall([
} }
//redirects browser to the pad's sanitized url if needed. otherwise, renders the html //redirects browser to the pad's sanitized url if needed. otherwise, renders the html
var goToPad = gotoPadCombinator(checkPadName, padManager); var goToPad = gotoPadCombinator(checkPadName, padManager);
//This is for making an api call, collecting all post information and passing it to the apiHandler
var apiCaller = apiCallerCombinator(serverName, apiLogger, apiHandler);
app.configure(configureCombinator(app, settings, basic_auth, log4js, httpLogger)); app.configure(configureCombinator(app, settings, basic_auth, log4js, httpLogger));
@ -498,7 +502,7 @@ async.waterfall([
var gets = {};
//serve static files //serve static files
app.get('/static/*', getStatic); app.get('/static/*', getStatic);
@ -508,14 +512,12 @@ async.waterfall([
//serve read only pad //serve read only pad
app.get('/ro/:id', getRoCombinator(serverName, {ro: readOnlyManager}, hasPadAccess, ERR, exporthtml)); app.get('/ro/:id', getRoCombinator(serverName, {ro: readOnlyManager}, hasPadAccess, ERR, exporthtml));
//serve pad.html under /p //serve pad.html under /p
app.get('/p/:pad', sendStaticIfPad(goToPad, padManager, path, "pad.html")); app.get('/p/:pad', sendStaticIfPad(goToPad, padManager, path, "pad.html"));
//serve timeslider.html under /p/$padname/timeslider //serve timeslider.html under /p/$padname/timeslider
app.get('/p/:pad/timeslider', sendStaticIfPad(goToPad, padManager, path, "timeslider.html")); app.get('/p/:pad/timeslider', sendStaticIfPad(goToPad, padManager, path, "timeslider.html"));
//serve timeslider.html under /p/$padname/timeslider //serve timeslider.html under /p/$padname/timeslider
//the above comment is wrong //the above comment is wrong
app.get('/p/:pad/:rev?/export/:type', getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler, serverName)); app.get('/p/:pad/:rev?/export/:type', getExportPadCombinator(goToPad, settings, hasPadAccess, exportHandler, serverName));
@ -523,10 +525,6 @@ async.waterfall([
//handle import requests //handle import requests
app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler)); app.post('/p/:pad/import', postImportPadCombinator(goToPad, settings, serverName, hasPadAccess, importHandler));
//This is for making an api call, collecting all post information and passing it to the apiHandler
var apiCaller = apiCallerCombinator(serverName, apiLogger, apiHandler);
//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)
{ {
@ -574,6 +572,9 @@ async.waterfall([
}); });
}); });
additionalSetup();
//let the server listen //let the server listen
app.listen(settings.port, settings.ip); app.listen(settings.port, settings.ip);
console.log("Server is listening at " + settings.ip + ":" + settings.port); console.log("Server is listening at " + settings.ip + ":" + settings.port);
@ -584,4 +585,9 @@ async.waterfall([
callback(null); callback(null);
} }
]); ]);
}
this.init = init;
init(function(){});