flywww / parseCloudCode

0 stars 0 forks source link

parse-server-example

Example project using the parse-server module on Express.

Read the full Parse Server guide here: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide

For Local Development

Getting Started With Heroku + Mongolab Development

With the Heroku Button

Deploy

Without It

Getting Started With AWS Elastic Beanstalk

With the Deploy to AWS Button

Without It

Getting Started With Microsoft Azure App Service

With the Deploy to Azure Button

Deploy to Azure

Without It

A detailed tutorial is available here: Azure welcomes Parse developers

Getting Started With Google App Engine

  1. Clone the repo and change directory to it
  2. Create a project in the Google Cloud Platform Console.
  3. Enable billing for your project.
  4. Install the Google Cloud SDK.
  5. Setup a MongoDB server. You have a few options:
    1. Create a Google Compute Engine virtual machine with MongoDB pre-installed.
    2. Use MongoLab to create a free MongoDB deployment on Google Cloud Platform.
  6. Modify app.yaml to update your environment variables.
  7. Delete Dockerfile
  8. Deploy it with gcloud preview app deploy

A detailed tutorial is available here: Running Parse server on Google App Engine

Getting Started With Scalingo

With the Scalingo button

Deploy to Scalingo

Without it

Using it

Before using it, you can access a test page to verify if the basic setup is working fine http://localhost:1337/test. Then you can use the REST API, the JavaScript SDK, and any of our open-source SDKs:

Example request to a server running locally:

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
  http://localhost:1337/parse/classes/GameScore

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{}' \
  http://localhost:1337/parse/functions/hello

Example using it via JavaScript:

Parse.initialize('myAppId','unused');
Parse.serverURL = 'https://whatever.herokuapp.com';

var obj = new Parse.Object('GameScore');
obj.set('score',1337);
obj.save().then(function(obj) {
  console.log(obj.toJSON());
  var query = new Parse.Query('GameScore');
  query.get(obj.id).then(function(objAgain) {
    console.log(objAgain.toJSON());
  }, function(err) {console.log(err); });
}, function(err) { console.log(err); });

Example using it on Android:

//in your application class

Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
  .applicationId("myAppId")
  .server("http://myServerUrl/parse/")   // '/' important after 'parse'
  .build());

ParseObject testObject = new ParseObject("TestObject");
testObject.put("foo", "bar");
testObject.saveInBackground();

Example using it on iOS (Swift):

//in your AppDelegate

Parse.initializeWithConfiguration(ParseClientConfiguration(block: { (configuration: ParseMutableClientConfiguration) -> Void in
  configuration.server = "https://<# Your Server URL #>/parse/" // '/' important after 'parse'
  configuration.applicationId = "<# Your APP_ID #>"
}))

You can change the server URL in all of the open-source SDKs, but we're releasing new builds which provide initialization time configuration of this property.