Adds ability to pass qs params to cloud code functions

This commit is contained in:
Florent Vilmart
2016-02-15 22:18:19 -05:00
parent e92176ce61
commit 8296d77f28
2 changed files with 34 additions and 2 deletions

View File

@@ -9,8 +9,11 @@ var router = new PromiseRouter();
function handleCloudFunction(req) {
if (Parse.Cloud.Functions[req.params.functionName]) {
const params = Object.assign({}, req.body, req.query);
if (Parse.Cloud.Validators[req.params.functionName]) {
var result = Parse.Cloud.Validators[req.params.functionName](req.body || {});
var result = Parse.Cloud.Validators[req.params.functionName](params);
if (!result) {
throw new Parse.Error(Parse.Error.SCRIPT_FAILED, 'Validation failed.');
}
@@ -19,7 +22,7 @@ function handleCloudFunction(req) {
return new Promise(function (resolve, reject) {
var response = createResponseObject(resolve, reject);
var request = {
params: req.body || {},
params: params,
master: req.auth && req.auth.isMaster,
user: req.auth && req.auth.user,
installationId: req.info.installationId