From 3c6141576f72d3d76d30fac9b61dbb590e0abc55 Mon Sep 17 00:00:00 2001 From: Florent Vilmart Date: Thu, 25 Feb 2016 12:59:19 -0500 Subject: [PATCH] Fixes --- src/Controllers/HooksController.js | 27 ++++++++++++++------------- src/index.js | 4 ++-- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Controllers/HooksController.js b/src/Controllers/HooksController.js index 9de061bf..d059396a 100644 --- a/src/Controllers/HooksController.js +++ b/src/Controllers/HooksController.js @@ -1,5 +1,6 @@ var DatabaseAdapter = require('../DatabaseAdapter'), - triggers = require('../triggers'); + triggers = require('../triggers'), + request = require('request'); const collection = "_Hooks"; export class HooksController { @@ -183,18 +184,18 @@ export class HooksController { } function wrapToHTTPRequest(hook) { - return function(request, response) { + return function(req, res) { var jsonBody = {}; - for(var i in request) { - jsonBody[i] = request[i]; + for(var i in req) { + jsonBody[i] = req[i]; } - if (request.object) { - jsonBody.object = request.object.toJSON(); - jsonBody.object.className = request.object.className; + if (req.object) { + jsonBody.object = req.object.toJSON(); + jsonBody.object.className = req.object.className; } - if (request.original) { - jsonBody.original = request.original.toJSON(); - jsonBody.original.className = request.original.className; + if (req.original) { + jsonBody.original = req.original.toJSON(); + jsonBody.original.className = req.original.className; } var jsonRequest = {}; jsonRequest.headers = { @@ -202,7 +203,7 @@ function wrapToHTTPRequest(hook) { } jsonRequest.body = JSON.stringify(jsonBody); - require("request").post(hook.url, jsonRequest, function(err, res, body){ + request.post(hook.url, jsonRequest, function(err, httpResponse, body){ var result; if (body) { if (typeof body == "string") { @@ -218,9 +219,9 @@ function wrapToHTTPRequest(hook) { } } if (err) { - return response.error(err); + return res.error(err); } else { - return response.success(result); + return res.success(result); } }); } diff --git a/src/index.js b/src/index.js index dd2cbcce..686e9c69 100644 --- a/src/index.js +++ b/src/index.js @@ -91,8 +91,8 @@ function ParseServer({ }) { // Initialize the node client SDK automatically - Parse.initialize(appId, javascriptKey || '', masterKey); - Parse.serverURL = serverURL || ''; + Parse.initialize(appId, javascriptKey, masterKey); + Parse.serverURL = serverURL; if (databaseAdapter) { DatabaseAdapter.setAdapter(databaseAdapter);