Ver código fonte

Merge pull request #8 from mattcreager/bring-the-button

Add a Heroku Button
Fosco Marotto 9 anos atrás
pai
commit
a72b7438a8
3 arquivos alterados com 37 adições e 8 exclusões
  1. 8 4
      README.md
  2. 23 0
      app.json
  3. 6 4
      index.js

+ 8 - 4
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`
 

+ 23 - 0
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"]
+}

+ 6 - 4
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: