├── cloud └── main.js ├── jsconfig.json ├── app.yaml ├── .ebextensions └── app.config ├── package.json ├── Dockerfile ├── .gitignore ├── app.json ├── scalingo.json ├── index.js ├── azuredeploy.json └── README.md /cloud/main.js: -------------------------------------------------------------------------------- 1 | 2 | Parse.Cloud.define('hello', function(req, res) { 3 | res.success('Hi'); 4 | }); 5 | -------------------------------------------------------------------------------- /jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "ES6", 4 | "module": "commonjs" 5 | } 6 | } -------------------------------------------------------------------------------- /app.yaml: -------------------------------------------------------------------------------- 1 | runtime: nodejs 2 | vm: true 3 | 4 | env_variables: 5 | # --REQUIRED-- 6 | DATABASE_URI: mongodb://localhost:27017/dev 7 | APP_ID: 8 | MASTER_KEY: 9 | # --OPTIONAL-- 10 | # FILE_KEY: 11 | # PARSE_MOUNT: /parse 12 | # CLOUD_CODE_MAIN: -------------------------------------------------------------------------------- /.ebextensions/app.config: -------------------------------------------------------------------------------- 1 | option_settings: 2 | aws:elasticbeanstalk:application:environment: 3 | PARSE_MOUNT: "/parse" 4 | APP_ID: "ReplaceWithAppID" 5 | MASTER_KEY: "ReplaceWithMasterKey" 6 | DATABASE_URI: "ReplaceWithDatabaseURI" 7 | NODE_ENV: "production" 8 | 9 | aws:elasticbeanstalk:container:nodejs: 10 | NodeCommand: "npm start" -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "parse-server-example", 3 | "version": "1.1.0", 4 | "description": "An example Parse API server using the parse-server module", 5 | "main": "index.js", 6 | "repository": { 7 | "type": "git", 8 | "url": "https://github.com/ParsePlatform/parse-server-example" 9 | }, 10 | "license": "MIT", 11 | "dependencies": { 12 | "express": "~4.2.x", 13 | "kerberos": "~0.0.x", 14 | "parse": "~1.6.12", 15 | "parse-server": "~2.1" 16 | }, 17 | "scripts": { 18 | "start": "node index.js" 19 | }, 20 | "engines": { 21 | "node": ">=4.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:latest 2 | 3 | RUN mkdir parse 4 | 5 | ADD . /parse 6 | WORKDIR /parse 7 | RUN npm install 8 | 9 | ENV APP_ID setYourAppId 10 | ENV MASTER_KEY setYourMasterKey 11 | ENV DATABASE_URI setMongoDBURI 12 | 13 | # Optional (default : 'parse/cloud/main.js') 14 | # ENV CLOUD_CODE_MAIN cloudCodePath 15 | 16 | # Optional (default : '/parse') 17 | # ENV PARSE_MOUNT mountPath 18 | 19 | EXPOSE 1337 20 | 21 | # Uncomment if you want to access cloud code outside of your container 22 | # A main.js file must be present, if not Parse will not start 23 | 24 | # VOLUME /parse/cloud 25 | 26 | CMD [ "npm", "start" ] 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Logs 2 | logs 3 | *.log 4 | 5 | # Runtime data 6 | pids 7 | *.pid 8 | *.seed 9 | 10 | # Directory for instrumented libs generated by jscoverage/JSCover 11 | lib-cov 12 | 13 | # Coverage directory used by tools like istanbul 14 | coverage 15 | 16 | # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) 17 | .grunt 18 | 19 | # node-waf configuration 20 | .lock-wscript 21 | 22 | # Compiled binary addons (http://nodejs.org/api/addons.html) 23 | build/Release 24 | 25 | # Dependency directory 26 | # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git 27 | node_modules 28 | 29 | # Emacs 30 | *~ 31 | -------------------------------------------------------------------------------- /app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Parse Server Example", 3 | "description": "An example Parse API server using the parse-server module", 4 | "repository": "https://github.com/ParsePlatform/parse-server-example", 5 | "logo": "https://avatars0.githubusercontent.com/u/1294580?v=3&s=200", 6 | "keywords": ["node", "express", "parse"], 7 | "env": { 8 | "PARSE_MOUNT": { 9 | "description": "Configure Parse API route.", 10 | "value": "/parse" 11 | }, 12 | "APP_ID": { 13 | "description": "A unique identifier for your app.", 14 | "value": "myAppId" 15 | }, 16 | "MASTER_KEY": { 17 | "description": "A key that overrides all permissions. Keep this secret.", 18 | "value": "myMasterKey" 19 | } 20 | }, 21 | "image": "heroku/nodejs", 22 | "addons": ["mongolab"] 23 | } 24 | -------------------------------------------------------------------------------- /scalingo.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Parse Server Example", 3 | "description": "An example Parse API server using the parse-server module", 4 | "repository": "https://github.com/ParsePlatform/parse-server-example", 5 | "logo": "https://avatars0.githubusercontent.com/u/1294580?v=3&s=200", 6 | "env": { 7 | "PARSE_MOUNT": { 8 | "description": "Configure Parse API route.", 9 | "value": "/parse" 10 | }, 11 | "APP_ID": { 12 | "description": "A unique identifier for your app.", 13 | "value": "" 14 | }, 15 | "MASTER_KEY": { 16 | "description": "A key that overrides all permissions. Keep this secret.", 17 | "value": "" 18 | }, 19 | "DATABASE_URI": { 20 | "description": "Connection string for your database.", 21 | "value": "$SCALINGO_MONGO_URL" 22 | } 23 | }, 24 | "addons": ["scalingo-mongodb"] 25 | } 26 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | // Example express application adding the parse-server module to expose Parse 2 | // compatible API routes. 3 | 4 | var express = require('express'); 5 | var ParseServer = require('parse-server').ParseServer; 6 | 7 | var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI; 8 | 9 | if (!databaseUri) { 10 | console.log('DATABASE_URI not specified, falling back to localhost.'); 11 | } 12 | 13 | var api = new ParseServer({ 14 | databaseURI: databaseUri || 'mongodb://localhost:27017/dev', 15 | cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', 16 | appId: process.env.APP_ID || 'myAppId', 17 | masterKey: process.env.MASTER_KEY || '' //Add your master key here. Keep it secret! 18 | }); 19 | // Client-keys like the javascript key or the .NET key are not necessary with parse-server 20 | // If you wish you require them, you can set them as options in the initialization above: 21 | // javascriptKey, restAPIKey, dotNetKey, clientKey 22 | 23 | var app = express(); 24 | 25 | // Serve the Parse API on the /parse URL prefix 26 | var mountPath = process.env.PARSE_MOUNT || '/parse'; 27 | app.use(mountPath, api); 28 | 29 | // Parse Server plays nicely with the rest of your web routes 30 | app.get('/', function(req, res) { 31 | res.status(200).send('I dream of being a web site.'); 32 | }); 33 | 34 | var port = process.env.PORT || 1337; 35 | app.listen(port, function() { 36 | console.log('parse-server-example running on port ' + port + '.'); 37 | }); 38 | -------------------------------------------------------------------------------- /azuredeploy.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#", 3 | "contentVersion": "1.0.0.0", 4 | "parameters": { 5 | "siteName": { 6 | "type": "string" 7 | }, 8 | "hostingPlanName": { 9 | "type": "string" 10 | }, 11 | "siteLocation": { 12 | "type": "string" 13 | }, 14 | "sku": { 15 | "type": "string", 16 | "allowedValues": [ 17 | "Free", 18 | "Shared", 19 | "Basic", 20 | "Standard" 21 | ], 22 | "defaultValue": "Free" 23 | }, 24 | "workerSize": { 25 | "type": "string", 26 | "allowedValues": [ 27 | "0", 28 | "1", 29 | "2" 30 | ], 31 | "defaultValue": "0" 32 | }, 33 | "mongoConnectionString": { 34 | "type": "string", 35 | "minLength": 5 36 | }, 37 | "parseAppId": { 38 | "type": "string", 39 | "minLength": 1, 40 | "defaultValue": "myAppId" 41 | }, 42 | "parseMasterKey": { 43 | "type": "string", 44 | "minLength": 1, 45 | "defaultValue": "myMasterKey" 46 | }, 47 | "repoURL": { 48 | "type": "string", 49 | "defaultValue": "https://github.com/parseplatform/parse-server-example.git", 50 | "metadata": { 51 | "description": "The URL for the GitHub repository that contains the project to deploy." 52 | } 53 | }, 54 | "branch": { 55 | "type": "string", 56 | "defaultValue": "master", 57 | "metadata": { 58 | "description": "The branch of the GitHub repository to use." 59 | } 60 | } 61 | }, 62 | "resources": [ 63 | { 64 | "apiVersion": "2014-06-01", 65 | "name": "[parameters('hostingPlanName')]", 66 | "type": "Microsoft.Web/serverFarms", 67 | "location": "[parameters('siteLocation')]", 68 | "properties": { 69 | "name": "[parameters('hostingPlanName')]", 70 | "sku": "[parameters('sku')]", 71 | "workerSize": "[parameters('workerSize')]", 72 | "numberOfWorkers": 1 73 | } 74 | }, 75 | { 76 | "apiVersion": "2014-06-01", 77 | "name": "[parameters('siteName')]", 78 | "type": "Microsoft.Web/Sites", 79 | "location": "[parameters('siteLocation')]", 80 | "dependsOn": [ 81 | "[concat('Microsoft.Web/serverFarms/', parameters('hostingPlanName'))]" 82 | ], 83 | "tags": { 84 | "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]": "empty" 85 | }, 86 | "properties": { 87 | "name": "[parameters('siteName')]", 88 | "serverFarm": "[parameters('hostingPlanName')]" 89 | }, 90 | "resources": [ 91 | { 92 | "apiVersion": "2014-04-01", 93 | "type": "config", 94 | "name": "web", 95 | "dependsOn": [ 96 | "[concat('Microsoft.Web/Sites/', parameters('siteName'))]" 97 | ], 98 | "properties": { 99 | "appSettings": [ 100 | { 101 | "name": "DATABASE_URI", 102 | "value": "[parameters('mongoConnectionString')]" 103 | }, 104 | { 105 | "name": "APP_ID", 106 | "value": "[parameters('parseAppId')]" 107 | }, 108 | { 109 | "name": "MASTER_KEY", 110 | "value": "[parameters('parseMasterKey')]" 111 | }, 112 | { 113 | "name": "WEBSITE_NODE_DEFAULT_VERSION", 114 | "value": "4.2.3" 115 | } 116 | ] 117 | } 118 | }, 119 | { 120 | "apiVersion": "2015-04-01", 121 | "name": "web", 122 | "type": "sourcecontrols", 123 | "dependsOn": [ 124 | "[resourceId('Microsoft.Web/Sites', parameters('siteName'))]" 125 | ], 126 | "properties": { 127 | "RepoUrl": "[parameters('repoURL')]", 128 | "branch": "[parameters('branch')]", 129 | "IsManualIntegration": true 130 | } 131 | } 132 | ] 133 | } 134 | ] 135 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # parse-server-example 2 | 3 | Example project using the [parse-server](https://github.com/ParsePlatform/parse-server) module on Express. 4 | 5 | Read the full Parse Server guide here: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide 6 | 7 | ### For Local Development 8 | 9 | * Make sure you have at least Node 4.1. `node --version` 10 | * Clone this repo and change directory to it. 11 | * `npm install` 12 | * Install mongo locally using http://docs.mongodb.org/master/tutorial/install-mongodb-on-os-x/ 13 | * Run `mongo` to connect to your database, just to make sure it's working. Once you see a mongo prompt, exit with Control-D 14 | * Run the server with: `npm start` 15 | * 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. 16 | * You now have a database named "dev" that contains your Parse data 17 | * Install ngrok and you can test with devices 18 | 19 | ### Getting Started With Heroku + Mongolab Development 20 | 21 | #### With the Heroku Button 22 | 23 | [![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) 24 | 25 | #### Without It 26 | 27 | * Clone the repo and change directory to it 28 | * Log in with the [Heroku Toolbelt](https://toolbelt.heroku.com/) and create an app: `heroku create` 29 | * Use the [MongoLab addon](https://elements.heroku.com/addons/mongolab): `heroku addons:create mongolab:sandbox` 30 | * 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` 31 | * Deploy it with: `git push heroku master` 32 | 33 | ### Getting Started With AWS Elastic Beanstalk 34 | 35 | #### With the Deploy to AWS Button 36 | 37 | 38 | 39 | #### Without It 40 | 41 | * Clone the repo and change directory to it 42 | * 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` 43 | * Create an environment and pass in MongoDB URI, App ID, and Master Key: `eb create --envvars DATABASE_URI=,APP_ID=,MASTER_KEY=` 44 | 45 | ### Getting Started With Microsoft Azure App Service 46 | 47 | #### With the Deploy to Azure Button 48 | 49 | [![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) 50 | 51 | #### Without It 52 | 53 | A detailed tutorial is available here: 54 | [Azure welcomes Parse developers](https://azure.microsoft.com/en-us/blog/azure-welcomes-parse-developers/) 55 | 56 | 57 | ### Getting Started With Google App Engine 58 | 59 | 1. Clone the repo and change directory to it 60 | 1. Create a project in the [Google Cloud Platform Console](https://console.cloud.google.com/). 61 | 1. [Enable billing](https://console.cloud.google.com/project/_/settings) for your project. 62 | 1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/). 63 | 1. Setup a MongoDB server. You have a few options: 64 | 1. Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb). 65 | 1. Use [MongoLab](https://mongolab.com/google/) to create a free MongoDB deployment on Google Cloud Platform. 66 | 1. Modify `app.yaml` to update your environment variables. 67 | 1. Delete `Dockerfile` 68 | 1. Deploy it with `gcloud preview app deploy` 69 | 70 | A detailed tutorial is available here: 71 | [Running Parse server on Google App Engine](https://cloud.google.com/nodejs/resources/frameworks/parse-server) 72 | 73 | ### Getting Started With Scalingo 74 | 75 | #### With the Scalingo button 76 | 77 | [![Deploy to Scalingo](https://cdn.scalingo.com/deploy/button.svg)](https://my.scalingo.com/deploy) 78 | 79 | #### Without it 80 | 81 | * Clone the repo and change directory to it 82 | * Log in with the [Scalingo CLI](http://cli.scalingo.com/) and create an app: `scalingo create my-parse` 83 | * Use the [Scalingo MongoDB addon](https://scalingo.com/addons/scalingo-mongodb): `scalingo addons-add scalingo-mongodb free` 84 | * Setup MongoDB connection string: `scalingo env-set DATABASE_URI='$SCALINGO_MONGO_URL'` 85 | * 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` 86 | * Deploy it with: `git push scalingo master` 87 | 88 | # Using it 89 | 90 | You can use the REST API, the JavaScript SDK, and any of our open-source SDKs: 91 | 92 | Example request to a server running locally: 93 | 94 | ``` 95 | curl -X POST \ 96 | -H "X-Parse-Application-Id: myAppId" \ 97 | -H "Content-Type: application/json" \ 98 | -d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \ 99 | http://localhost:1337/parse/classes/GameScore 100 | 101 | curl -X POST \ 102 | -H "X-Parse-Application-Id: myAppId" \ 103 | -H "Content-Type: application/json" \ 104 | -d '{}' \ 105 | http://localhost:1337/parse/functions/hello 106 | ``` 107 | 108 | Example using it via JavaScript: 109 | 110 | ``` 111 | Parse.initialize('myAppId','unused'); 112 | Parse.serverURL = 'https://whatever.herokuapp.com'; 113 | var obj = new Parse.Object('GameScore'); 114 | obj.set('score',1337); 115 | obj.save().then(function(obj) { 116 | console.log(obj.toJSON()); 117 | var query = new Parse.Query('GameScore'); 118 | query.get(obj.id).then(function(objAgain) { 119 | console.log(objAgain.toJSON()); 120 | }, function(err) {console.log(err); }); 121 | }, function(err) { console.log(err); }); 122 | ``` 123 | 124 | Example using it on Android: 125 | ``` 126 | //in your application class 127 | 128 | Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) 129 | .applicationId("myAppId") 130 | .clientKey("myClientKey") 131 | .server("http://myServerUrl/parse/") // '/' important after 'parse' 132 | .build()); 133 | 134 | ParseObject testObject = new ParseObject("TestObject"); 135 | testObject.put("foo", "bar"); 136 | testObject.saveInBackground(); 137 | 138 | ``` 139 | 140 | 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. 141 | --------------------------------------------------------------------------------