Skip to content

Latest commit

 

History

History
105 lines (65 loc) · 3.59 KB

README.md

File metadata and controls

105 lines (65 loc) · 3.59 KB

bloom-parse-server

This is the database backend for bloom-library.org, using the parse-server module.

Here is the full Parse Server guide.

Set Up For Local Development

  1. Make sure you have at least Node 4.3.

    node --version

  2. Clone this repo and go into its directory, and install or update the dependencies:

    npm install

  3. Install mongodb server

  4. 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

  5. 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

  6. Run Parse Dashboard:

    npm install parse-dashboard --global
    parse-dashboard --appId myAppId --masterKey "123" --serverURL
    

    This will respond that it is available at http://0.0.0.0, but actually it is at http://localhost.

  7. 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.

Cloud Code

Normally you will only touch the "cloud code", found in cloud/main.js.

Sample Queries

curl -X POST \
  -H "X-Parse-Application-Id: myAppId" \
  -H "Content-Type: application/json" \
  -d '{}' \
  http://localhost:1337/parse/functions/hello

Azure Setup

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:

  1. Create the mongodb on mlab.com, making sure to select Azure and the same datacenter. Failing to do this increases response times by 3x.

  2. In Azure, create a new "Web App" App Service

  3. In Azure:App Service:Application 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://.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.

  4. 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.

    Question: does the service shut down while this is happening?

  5. 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 for functions/testDB, which worked. Then I tried functions/setupTables again, and this time it worked.

  6. TODO: Backup, Logging setup.