Missed merge requires correction

This commit is contained in:
Dominic Bosch 2014-04-01 23:47:54 +02:00
commit 3dc35827b2
11 changed files with 30 additions and 28 deletions

View file

@ -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

View file

@ -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}

View file

@ -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?'
});
}
};

View file

@ -117,4 +117,4 @@ exports.testListener = ( test ) =>
test.ok false, 'testListener failed: ' + answ.message
test.done()
console.log 'init listener added'
console.log 'init listener added'

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;

View file

@ -1,4 +1,4 @@
// Generated by CoffeeScript 1.6.3
// Generated by CoffeeScript 1.7.1
(function() {
var fOnLoad;