js-adapters/router.js in rhoconnect-4.0.0.beta.10 vs js-adapters/router.js in rhoconnect-4.0.0.beta.12

- old
+ new

@@ -4,50 +4,53 @@ var router = function(json){ switch(json['route']){ case 'request': try { var request = new Request(); - var response = new Response(); + var resp1 = new Response(); request.params = json['args']; request.header = {'request_id':json['request_id'],'route':json['route']}; request.model = json['model']; - response.header = {'request_id':json['request_id'],'route':'response'}; + resp1.currentUser = json['user']; + resp1.header = {'request_id':json['request_id'],'route':'response'}; //if calling model function directly load file first if(json['klss'] !== undefined){ + var model_dir = ''; if(process.argv[3] == 'test' ){ - var model_dir = process.cwd() + "/spec/apps/rhotestapp/models/js/"; + model_dir = process.cwd() + "/spec/apps/rhotestapp/models/js/"; } else{ - var model_dir = process.cwd() + "/models/js/"; + model_dir = process.cwd() + "/models/js/"; } //console.error("path is: ******* " + model_dir + json['klss'] + '.js'); var mod = require(model_dir + json['klss'] + '.js'); - mod[ json['function']](response); + mod[json['function']](resp1); } else{ //console.error("reg routes are: " + registeredRoutes[json['url']]); - registeredRoutes[json['url']](request,response); + registeredRoutes[json['url']](request,resp1); } break; } catch(e){ console.error("Node.js error caught: "+ e); console.error("Backtrace: " + e.stack); - response.exception = {"error": e}; - response.send(null); + resp1.exception = {"error": e}; + resp1.send(null); } break; case 'response': //console.error("result callback is: " + json['callback']) var cback = json['callback']; json['callback'] = undefined; - var response = new Response(); - response.header = {'request_id':json['request_id'],'route':'response'}; - response.result = json['result']; + var resp2 = new Response(); + resp2.header = {'request_id':json['request_id'],'route':'response'}; + resp2.result = json['result']; - rhoconnectCallbacks[cback](response); + + rhoconnectCallbacks[cback](resp2); delete rhoconnectCallbacks[cback]; break; case 'deregister': var br = require('ballroom'); br.exitNodejs(); \ No newline at end of file