Skip to content

Commit a6232bb

Browse files
committed
Merge pull request #70 from thesandlord/master
Env vars are parsed from app.yaml on local run. Added SERVER_URL to app.yaml
2 parents aaadacf + e05c874 commit a6232bb

File tree

5 files changed

+28
-28
lines changed

5 files changed

+28
-28
lines changed

appengine/parse-server/README.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,22 @@ app to [Google App Engine Managed VMs](https://cloud.google.com/appengine).
1111
1. Setup a MongoDB server. Here are two possible options:
1212
1. Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb).
1313
1. Use [MongoLab](https://mongolab.com/google/) to create a free MongoDB deployment on Google Cloud Platform.
14-
15-
## Running locally
14+
15+
## Downloading Files
1616

1717
1. `git clone https://github.com/GoogleCloudPlatform/nodejs-docs-samples.git`
1818
1. `cd appengine/parse-server`
19+
20+
## Running locally
21+
1922
1. `npm install`
20-
1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/server.js#L23).
23+
1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json).
2124
1. `npm start`
2225

2326
## Deploy
2427

25-
1. Modify `app.yaml` as needed.
26-
1. `gcloud preview app deploy`
28+
1. Set the necessary [environment variables](https://github.com/GoogleCloudPlatform/nodejs-docs-samples/blob/master/appengine/parse-server/config.json).
29+
1. `npm run deploy`
2730

2831
Refer to the [appengine/README.md](../README.md) file for more instructions on
2932
running and deploying.

appengine/parse-server/app.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,6 @@
1515
runtime: nodejs
1616
vm: true
1717

18-
env_variables:
19-
# Your MongoDB URI, e.g. mongodb://user:[email protected]:27017/db
20-
DATABASE_URI: mongodb://localhost:27017/dev
21-
# Absolute path to your cloud code main.js file
22-
# CLOUD_PATH: <your-cloud-path>
23-
# App id
24-
# REQUIRED
25-
APP_ID: <your-app-id>
26-
# master key
27-
# REQUIRED
28-
MASTER_KEY: <your-master-key>
29-
# file key
30-
FILE_KEY: <your-file-key>
31-
# Mount path for Parse API
32-
PARSE_MOUNT_PATH: /parse
33-
3418
skip_files:
3519
# Don't deploy node_modules folder
3620
- ^(.*/)?.*/node_modules/.*$

appengine/parse-server/config.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"DATABASE_URI": "mongodb://localhost:27017/dev",
3+
"CLOUD_PATH": "./cloud/main.js",
4+
"APP_ID": "<your-app-id>",
5+
"MASTER_KEY": "<your-master-key>",
6+
"FILE_KEY": "<your-file-key>",
7+
"PARSE_MOUNT_PATH": "/parse",
8+
"SERVER_URL": "<your-server-url>"
9+
}

appengine/parse-server/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
},
1616
"dependencies": {
1717
"express": "^4.13.4",
18-
"parse-server": "^2.1.3"
18+
"parse-server": "^2.1.3",
19+
"nconf": "0.8.4"
1920
}
2021
}

appengine/parse-server/server.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,20 @@
1616

1717
// [START app]
1818
var express = require('express');
19+
var nconf = require('nconf');
1920
var ParseServer = require('parse-server').ParseServer;
2021

22+
nconf.argv().env().file({ file: 'config.json' });
23+
2124
var app = express();
2225

2326
var parseServer = new ParseServer({
24-
databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
25-
cloud: process.env.CLOUD_PATH || __dirname + '/cloud/main.js',
26-
appId: process.env.APP_ID,
27-
masterKey: process.env.MASTER_KEY,
28-
fileKey: process.env.FILE_KEY,
29-
serverURL: process.env.SERVER_URL
27+
databaseURI: nconf.get('DATABASE_URI') || 'mongodb://localhost:27017/dev',
28+
cloud: nconf.get('CLOUD_PATH') || __dirname + '/cloud/main.js',
29+
appId: nconf.get('APP_ID'),
30+
masterKey: nconf.get('MASTER_KEY'),
31+
fileKey: nconf.get('FILE_KEY'),
32+
serverURL: nconf.get('SERVER_URL')
3033
});
3134

3235
// Mount the Parse API server middleware to /parse

0 commit comments

Comments
 (0)