Created
May 27, 2013 20:58
-
-
Save gfosco/953f05aec7e390701723 to your computer and use it in GitHub Desktop.
beginnings of a wrapper script to test cloud code functions locally
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// cclocal | |
Parse = require('parse'); | |
Parse.Cloud = {}; | |
Parse.Cloud.Functions = {}; | |
Parse.Cloud.define = function(funcName,func) { | |
Parse.Cloud.Functions[funcName] = func; | |
} | |
Parse.Cloud.run = function(funcName, req, res) { | |
Parse.Cloud.Functions[funcName](req, res); | |
} | |
Parse.Cloud.beforeSave = function(funcName, func) { | |
Parse.Cloud.Functions['beforesave_' + funcName] = func; | |
} | |
Parse.Cloud.afterSave = function(funcName, func) { | |
Parse.Cloud.Functions['aftersave_' + funcName] = func; | |
} | |
function responseObject(callback) { | |
var res = {}; | |
res.success = function(out) { | |
callback(out); | |
}; | |
res.error = function(out1, out2) { | |
callback(out2); | |
}; | |
return res; | |
} | |
var main = require('./parse/cloud/main.js'); | |
var http = require('http'); | |
var router = require('choreographer').router(); | |
router.get('/', function (req, res) { | |
Parse.Cloud.run('hello',{},responseObject(function (out) { | |
console.log(out); | |
res.end(out); | |
})); | |
}) | |
http.createServer(router).listen(80); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
npm install parse
npm install choreographer