diff --git a/README.md b/README.md index 5529765fff..51252cade6 100644 --- a/README.md +++ b/README.md @@ -18,11 +18,15 @@ Read the full server guide here: https://parse.com/docs/server/guide ### 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 -* Use the Heroku Toolbelt to log in and prepare the app -* Use the MongoLab addon: `heroku addons:create mongolab:sandbox` -* Use `heroku config` and note the URI provided by MongoLab under the var MONGOLAB_URI -* Copy this URI and set it as a new config variable: `heroku config:set DATABASE_URI=mongodb://...` +* 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` diff --git a/app.json b/app.json new file mode 100644 index 0000000000..a4b9a67dc3 --- /dev/null +++ b/app.json @@ -0,0 +1,23 @@ +{ + "name": "Parse Server Example", + "description": "An example Parse API server using the parse-server module", + "repository": "https://github.com/ParsePlatform/parse-server-example", + "logo": "https://avatars0.githubusercontent.com/u/1294580?v=3&s=200", + "keywords": ["node", "express", "parse"], + "env": { + "PARSE_MOUNT": { + "description": "Configure Parse API route.", + "value": "/parse" + }, + "APP_ID": { + "description": "A unique identifier for your app.", + "value": "myAppId" + }, + "MASTER_KEY": { + "description": "A key that overrides all permissions. Keep this secret.", + "value": "myMasterKey" + } + }, + "image": "heroku/nodejs", + "addons": ["mongolab"] +} diff --git a/index.js b/index.js index 85b6fb200a..aa0aed10e2 100644 --- a/index.js +++ b/index.js @@ -5,15 +5,17 @@ var express = require('express'); var ParseServer = require('parse-server').ParseServer; var http = require('http'); -if (!process.env.DATABASE_URI) { +var databaseUri = process.env.DATABASE_URI || process.env.MONGOLAB_URI + +if (!databaseUri) { console.log('DATABASE_URI not specified, falling back to localhost.'); } var api = new ParseServer({ - databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev', + databaseURI: databaseUri || 'mongodb://localhost:27017/dev', cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js', - appId: 'myAppId', - masterKey: 'myMasterKey' + appId: process.env.APP_ID || 'myAppId', + masterKey: process.env.MASTER_KEY || 'myMasterKey' }); // Client-keys like the javascript key or the .NET key are not necessary with parse-server // If you wish you require them, you can set them as options in the initialization above: