diff --git a/coffee/components-manager.coffee b/coffee/components-manager.coffee index a086737..c67f853 100644 --- a/coffee/components-manager.coffee +++ b/coffee/components-manager.coffee @@ -57,37 +57,36 @@ exports.addListener = ( evt, eh ) => db.getRules ( err, obj ) => @ee.emit 'init', rule for id, rule of obj - ### Processes a user request coming through the request-handler. - `user` is the user object as it comes from the DB. - `oReq` is the request object that contains: - `command` as a string - `payload` an optional stringified JSON object -The callback function `cb( obj )` will receive an object containing the HTTP -response code and a corresponding message. +The callback function `callback( obj )` will receive an object +containing the HTTP response code and a corresponding message. -@public processRequest ( *user, oReq, cb* ) +@public processRequest ( *user, oReq, callback* ) @param {Object} user @param {Object} oReq -@param {function} cb +@param {function} callback ### -exports.processRequest = ( user, oReq, cb ) => +exports.processRequest = ( user, oReq, callback ) => if not oReq.payload oReq.payload = '{}' try dat = JSON.parse oReq.payload catch err - return cb + return callback code: 404 message: 'You had a strange payload in your request!' if commandFunctions[oReq.command] - commandFunctions[oReq.command] user, dat, cb + commandFunctions[oReq.command] user, dat, callback else - cb + callback code: 404 - message: 'Strange request!' + message: 'What do you want from me?' hasRequiredParams = ( arrParams, oReq ) -> answ = @@ -248,4 +247,4 @@ commandFunctions = code: 400 message: 'bad bad request...' console.log err - cb answ + cb answ \ No newline at end of file diff --git a/documentation/techdoc/techdoc.tex b/documentation/techdoc/techdoc.tex index 7b54ac6..5e3740d 100644 --- a/documentation/techdoc/techdoc.tex +++ b/documentation/techdoc/techdoc.tex @@ -112,7 +112,10 @@ and the engine fetches the same but modularized code from the npm repository via this also allows us to send privately stored modules and rules encrypted to the user, which will then see it decrypted after it arrived at the browser +\subsection{Request formats} +\subsubsection{User commands} +object that has a command as string and an optional payload as a stringified JSON \bibliography{user-manual} diff --git a/js-coffee/components-manager.js b/js-coffee/components-manager.js index 404e1da..6a16e7d 100644 --- a/js-coffee/components-manager.js +++ b/js-coffee/components-manager.js @@ -76,17 +76,17 @@ Components Manager - `oReq` is the request object that contains: - `command` as a string - `payload` an optional stringified JSON object - The callback function `cb( obj )` will receive an object containing the HTTP - response code and a corresponding message. + The callback function `callback( obj )` will receive an object + containing the HTTP response code and a corresponding message. - @public processRequest ( *user, oReq, cb* ) + @public processRequest ( *user, oReq, callback* ) @param {Object} user @param {Object} oReq - @param {function} cb + @param {function} callback */ - exports.processRequest = function(user, oReq, cb) { + exports.processRequest = function(user, oReq, callback) { var dat, err; if (!oReq.payload) { oReq.payload = '{}'; @@ -95,17 +95,17 @@ Components Manager dat = JSON.parse(oReq.payload); } catch (_error) { err = _error; - return cb({ + return callback({ code: 404, message: 'You had a strange payload in your request!' }); } if (commandFunctions[oReq.command]) { - return commandFunctions[oReq.command](user, dat, cb); + return commandFunctions[oReq.command](user, dat, callback); } else { - return cb({ + return callback({ code: 404, - message: 'Strange request!' + message: 'What do you want from me?' }); } }; diff --git a/testing/test_components-manager.coffee b/testing/test_components-manager.coffee index 86d710c..3b992a6 100644 --- a/testing/test_components-manager.coffee +++ b/testing/test_components-manager.coffee @@ -117,4 +117,4 @@ exports.testListener = ( test ) => test.ok false, 'testListener failed: ' + answ.message test.done() - console.log 'init listener added' \ No newline at end of file + console.log 'init listener added' diff --git a/webpages/handlers/js/admin.js b/webpages/handlers/js/admin.js index d133294..8d7b0aa 100644 --- a/webpages/handlers/js/admin.js +++ b/webpages/handlers/js/admin.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/error.js b/webpages/handlers/js/error.js index 2bb94fc..c97b3f0 100644 --- a/webpages/handlers/js/error.js +++ b/webpages/handlers/js/error.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/forge_action_invoker.js b/webpages/handlers/js/forge_action_invoker.js index d1073f2..d46edb9 100644 --- a/webpages/handlers/js/forge_action_invoker.js +++ b/webpages/handlers/js/forge_action_invoker.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/forge_event.js b/webpages/handlers/js/forge_event.js index 90e5936..4951d18 100644 --- a/webpages/handlers/js/forge_event.js +++ b/webpages/handlers/js/forge_event.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/forge_event_poller.js b/webpages/handlers/js/forge_event_poller.js index 3001d4b..edccd11 100644 --- a/webpages/handlers/js/forge_event_poller.js +++ b/webpages/handlers/js/forge_event_poller.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/forge_rule.js b/webpages/handlers/js/forge_rule.js index f0c22ef..fb43119 100644 --- a/webpages/handlers/js/forge_rule.js +++ b/webpages/handlers/js/forge_rule.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad; diff --git a/webpages/handlers/js/login.js b/webpages/handlers/js/login.js index 0f62b66..348fc68 100644 --- a/webpages/handlers/js/login.js +++ b/webpages/handlers/js/login.js @@ -1,4 +1,4 @@ -// Generated by CoffeeScript 1.6.3 +// Generated by CoffeeScript 1.7.1 (function() { var fOnLoad;