From 23d63697460d6636285aa79c895c49c2427c3a5d Mon Sep 17 00:00:00 2001 From: calcnerd256 Date: Mon, 30 Jan 2012 10:47:06 -0600 Subject: [PATCH] added some comments to the server setup to explain what additionalSetup does and why --- node/server.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/node/server.js b/node/server.js index 42f86daff..4f3ef9bad 100644 --- a/node/server.js +++ b/node/server.js @@ -68,8 +68,14 @@ exports.maxAge = 1000*60*60*6; log4js.setGlobalLogLevel(settings.loglevel); function init(additionalSetup){ - if("function" != typeof additionalSetup) additionalSetup = function(){}; -async.waterfall([ + //additionalSetup is an optional argument that must be a function + //the purpose of additionalSetup is + //to allow whoever initializes the server to add functionality + //before the server begins listening + if("function" != typeof additionalSetup) + //the default value for initialSetup is a no-op + additionalSetup = function additionalSetup(app, db, managers, handlers){}; + async.waterfall([ //initalize the database function (callback) { @@ -414,10 +420,13 @@ async.waterfall([ }); }); + //additionalSetup is a hook for modifying the app before it begins listening + //some things such a hook might need are the app itself, the database, and any managers and handlers it might want to use + //rather than passing the managers and handlers one by one, each of those collections is passed as a dictionary additionalSetup( app, db, { - ro: readOnlyManager, + "ro": readOnlyManager, pad: padManager, security: securityManager },