Added ability to set server url for Parse JS client SDK whithin ParseServer constructor

This commit is contained in:
Andrew Mihailov
2016-02-01 19:23:05 +02:00
parent 25a0fbeaee
commit a65f2d13ab
2 changed files with 8 additions and 2 deletions

View File

@@ -18,6 +18,7 @@ There is a development wiki here on GitHub: https://github.com/ParsePlatform/par
* cloud - The absolute path to your cloud code main.js file * cloud - The absolute path to your cloud code main.js file
* fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse. * fileKey - For migrated apps, this is necessary to provide access to files already hosted on Parse.
* facebookAppIds - An array of valid Facebook application IDs. * facebookAppIds - An array of valid Facebook application IDs.
* serverURL - URL which will be used by Cloud Code functions to make requests against.
#### Client key options: #### Client key options:
@@ -45,6 +46,8 @@ var ParseServer = require('parse-server').ParseServer;
var app = express(); var app = express();
var port = process.env.PORT || 1337;
// Specify the connection string for your mongodb database // Specify the connection string for your mongodb database
// and the location to your Parse cloud code // and the location to your Parse cloud code
var api = new ParseServer({ var api = new ParseServer({
@@ -52,7 +55,8 @@ var api = new ParseServer({
cloud: '/home/myApp/cloud/main.js', // Provide an absolute path cloud: '/home/myApp/cloud/main.js', // Provide an absolute path
appId: 'myAppId', appId: 'myAppId',
masterKey: 'mySecretMasterKey', masterKey: 'mySecretMasterKey',
fileKey: 'optionalFileKey' fileKey: 'optionalFileKey',
serverURL: 'http://localhost:' + port + '/parse' // Don't forget to change to https if needed
}); });
// Serve the Parse API on the /parse URL prefix // Serve the Parse API on the /parse URL prefix
@@ -63,7 +67,6 @@ app.get('/', function(req, res) {
res.status(200).send('Express is running here.'); res.status(200).send('Express is running here.');
}); });
var port = process.env.PORT || 1337;
app.listen(port, function() { app.listen(port, function() {
console.log('parse-server-example running on port ' + port + '.'); console.log('parse-server-example running on port ' + port + '.');
}); });

View File

@@ -72,6 +72,9 @@ function ParseServer(args) {
// Initialize the node client SDK automatically // Initialize the node client SDK automatically
Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey); Parse.initialize(args.appId, args.javascriptKey || '', args.masterKey);
if(args.serverURL) {
Parse.serverURL = args.serverURL;
}
// This app serves the Parse API directly. // This app serves the Parse API directly.
// It's the equivalent of https://api.parse.com/1 in the hosted Parse API. // It's the equivalent of https://api.parse.com/1 in the hosted Parse API.