Source

Deploying a Parse Server to Heroku

Last updated 05 February 2016

Parse Server is a Parse API compatible Express router package and an alternative to the hosted Parse service.

This guide shows you how to deploy and configure a Parse server on Heroku. A Heroku account is required, sign-up for free.

Source for this article's reference application is available on GitHub. You can deploy the reference application using the Heroku Button below.

Deploy

Create an app

To create a new app, visit the Heroku Dashboard and select "Create new app" from the drop-down menu.

Select "Create new app" from the drop-down

Install a MongoDB add-on

Click the Resources tab, then select and install the MongoLab add-on.

Search for and select the MongoLab add-on

Connect to GitHub

Before connecting the parse-server-example to your Heroku app, fork the official example.

To connect the parse-server-example to your Heroku app, you must enable the GitHub integration, and connect the app to the parse-server-example repo.

Connect to your forked parse-server-example repo

When the connection is established, the dashboard will update.

A screenshot of the UI, post connection

Deploy

Trigger a manual deployment of the master branch.

A screenshot of the manual deployment UI

Once the build is complete, click "view" to open the app in a new browser tab.

A screenshot of the "View" button If the parse-server-example has been successfully deployed, you will now see, "I dream of being a web site."

You can now use the standard REST interface, JavaScript SDK, and any of the Parse open-source SDKs.

$ curl -X POST
  -H "X-Parse-Application-Id: myAppId"
  -H "Content-Type: application/json"
  -d '{}'
  https://example.herokuapp.com/parse/functions/hello
..
{"result":"Hi"}%

Configuring your Parse server with config vars

The Parse server is configured during instantiation. The index.js file in the parse-server-example specifies defaults, which are superseded by config vars, made available to our application via environment variables.

    var api = new ParseServer({
      databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
      cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
      appId: process.env.APP_ID || 'myAppId',
      masterKey: process.env.MASTER_KEY || 'myMasterKey'
    });

    var app = express();

    var mountPath = process.env.PARSE_MOUNT || '/parse';

You can edit config vars from Settings tab in Dashboard:

A screenshot of the Settings tab

Migrating existing Parse data

For more information about migrating an existing Parse application to Heroku, see the official Parse migration guide.

For support related to the migration of your Parse data to the MongoLab Heroku add-on, please contact MongoLab support.

 

The Parse hosted service will be retired on January 28, 2017.


results matching ""

    No results matching ""