# parse-server-example Example project using the parse-server module on Express. Read the full server guide here: https://parse.com/docs/server/guide ### For Local Development * Make sure you have at least Node 4.1. `node --version` * Clone this repo and change directory to it. * `npm install` * Install mongo locally using http://docs.mongodb.org/master/tutorial/install-mongodb-on-os-x/ * Run `mongo` to connect to your database, just to make sure it's working. Once you see a mongo prompt, exit with Control-D * Run the server with: `npm start` * By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run `export PARSE_MOUNT=/1` before launching the server. * You now have a database named "dev" that contains your Parse data * Install ngrok and you can test with devices ### Getting Started With Heroku + Mongolab Development #### With the Heroku Button [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) #### Without It * Clone the repo and change directory to it * Log in with the [Heroku Toolbelt](https://toolbelt.heroku.com/) and create an app: `heroku create` * Use the [MongoLab addon](https://elements.heroku.com/addons/mongolab): `heroku addons:create mongolab:sandbox` * By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run `heroku config:set PARSE_MOUNT=/1` * Deploy it with: `git push heroku master` ### Getting Started With AWS Elastic Beanstalk #### With the Deploy to AWS Button [![Deploy to AWS](http://d0.awsstatic.com/product-marketing/Elastic%20Beanstalk/deploy-to-aws.png)](https://console.aws.amazon.com/elasticbeanstalk/home?region=us-west-2#/newApplication?applicationName=ParseServer&solutionStackName=Node.js&tierName=WebServer&sourceBundleUrl=https://s3.amazonaws.com/elasticbeanstalk-samples-us-east-1/eb-parse-server-sample/parse-server-example.zip) #### Without It * Clone the repo and change directory to it * Log in with the [AWS Elastic Beanstalk CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html), select a region, and create an app: `eb init` * Create an environment and pass in MongoDB URI, App ID, and Master Key: `eb create --envvars DATABASE_URI=,APP_ID=,MASTER_KEY=` ### Getting Started Microsoft Azure App Service #### With the Deploy to Azure Button [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) #### Without It A detailed tutorial is available here: [Azure welcomes Parse developers](https://azure.microsoft.com/en-us/blog/azure-welcomes-parse-developers/) ### Getting Started With Scalingo #### With the Scalingo button [![Deploy to Scalingo](https://cdn.scalingo.com/deploy/button.svg)](https://my.scalingo.com/deploy) #### Without it * Clone the repo and change directory to it * Log in with the [Scalingo CLI](http://cli.scalingo.com/) and create an app: `scalingo create my-parse` * Use the [Scalingo MongoDB addon](https://scalingo.com/addons/scalingo-mongodb): `scalingo addons-add scalingo-mongodb free` * Setup MongoDB connection string: `scalingo env-set DATABASE_URI='$SCALINGO_MONGO_URL'` * By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run `scalingo env-set PARSE_MOUNT=/1` * Deploy it with: `git push scalingo master` ### Using it 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); }); ``` 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.