This is the database backend for bloom-library.org, using the parse-server module.
Here is the full Parse Server guide.
-
Make sure you have at least Node 4.3.
node --version
-
Clone this repo and go into its directory, and install or update the dependencies:
npm install
-
Install mongodb server
-
Give mongodb a blank directory to work with, and run it:
c:\Program Files\MongoDB\Server\3.2\bin>mongod.exe --dbpath x:\temp\mongodata
-
Start up this server:
npm start
Or, to debug, open bloom-parse-server in vscode, F5 (Debug: Launch via NPM). Note that this sets the masterid to "123", via an environment variable.
To verify that it is running, open a browser to http://localhost:1337/test
-
Run Parse Dashboard:
npm install parse-dashboard --global parse-dashboard --appId myAppId --masterKey "123" --serverURL http://localhost:1337/parse
This will respond that it is available at http://0.0.0.0, but actually it is at http://localhost.
-
Setup or update the mongodb Schema
curl -X POST -H "X-Parse-Application-Id: myAppId" -H "X-Parse-Master-Key: 123" -d "{}" http://localhost:1337/parse/functions/setupTables
You should get
{"result":"SetupTables ran to completion."}
and see the tables in the dashboard.
Normally you will only touch the "cloud code", found in cloud/main.js.
curl -X POST \
-H "X-Parse-Application-Id: myAppId" \
-H "Content-Type: application/json" \
-d '{}' \
http://localhost:1337/parse/functions/hello
We are running three different services:
- bloom-parse-server-unittest
- bloom-parse-server-develop
- bloom-parse-server-production
Each is backed by a single mongodb at mlab.com. This is how they were made:
-
Create the mongodb on mlab.com, making sure to select Azure and the same datacenter. Failing to do this increases response times by 3x.
-
In Azure, create a new "Web App" App Service
-
In Azure:App Service:Application Settings:App Settings, create these settings:
DATABASE_URI mongodb://account:[email protected]:port/database
APP_ID you make this up.
MASTER_KEY you make this up
SERVER_URL http://[azure app service name].azurewebsites.net/parse
Note: Don't leave off that /parse in the SERVER_URL!
REST API: parse.com used this (not clear what the actual environment variable would be) but as far as I can tell, the open source Parse-Server does not.
-
In Azure:App Service:Deployment Options, point it at this github repository, with the appropriate branch. A few minutes later, parse-server will be running. Note that Azure apparently does the
npm install
automatically, as needed. Not also that it automatically redepoys when github notifies it of a checkin on the branch it is watching.TODO: Set up Deployment "Slots".
-
We never touch the schema using the Parse Dashboard or letting queries automagically add clases or fields. Instead, we set up the schema using a Cloud Code function
setupTables
. If you haven't set up the database already, follow instructions shown above under "Setup or update the mongodb Schema". Use Azure:App Service:Log stream to monitor progress. Note: During one setup, I found this can be flaky, perhaps becuase I jumped the gun. So instead I did the curl post forfunctions/testDB
, which worked. Then I triedfunctions/setupTables
again, and this time it worked. -
TODO: Backup, Logging setup.