/parse-backend

Example server using Express and the parse-server module.

Primary LanguageJavaScript

parse-backend

Fork using the parse-server v4.5.0 and parse-dashboard module on Express. Read the full Parse Server Guide for more information.

Table of Contents

Local Development

Prepare Installation

  1. Login as root to an Ubuntu 20.04 Server
  2. Update Ubuntu packet manager: apt-get update
  3. Upgrade the Ubuntu packages already installed: apt-get upgrade
  4. Install git: apt-get install git
  5. Add an non-root user used to run the Express app: adduser runner

Install MongoDB

  1. Install MongoDB. By default, MongoDB is available in the Ubuntu 20.04 default repository: apt-get install mongodb-server -y
  2. Verify MongoDB status: systemctl status mongodb
  3. which returns: ● mongodb.service - An object/document-oriented database Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled) Active: active (running) since Tue 2020-11-03 15:43:50 UTC; 22s ago Docs: man:mongod(1) Main PID: 718 (mongod) Tasks: 23 (limit: 4915) Memory: 42.2M CGroup: /system.slice/mongodb.service └─718 /usr/bin/mongod --unixSocketPrefix=/run/mongodb --config /etc/mongodb.conf

Nov 03 15:43:50 scw-friendly-edison systemd[1]: Started An object/document-oriented database.

Install NodeJS

  1. Add an external repository for the required version of NodeJS: curl -sL https://deb.nodesource.com/setup_lts.x | bash -
  2. Install NodeJS: apt-get install nodejs -y
  3. Verify the NodeJS version: node --version
  4. Allow ports 80 and 443 to be opened by other users than root: setcap cap_net_bind_service=+ep /usr/bin/node

Install Express app

  1. Login to the server as the non-root user "runner" created above
  2. Clone this repository: git clone
  3. Change in the work directory: cd parse-backend
  4. Install: npm install

Change Env Variables

Using Parse Server

Health Check

You can use the /health endpoint to verify that Parse Server is up and running. For example, for local deployment, enter this URL in your browser:

http://localhost:1337/parse/health

If you deployed Parse Server remotely, change the URL accordingly.

APIs and SDKs

Use the REST API, GraphQL API or any of the Parse SDKs to see Parse Server in action. Parse Server comes with a variety of SDKs to cover most common ecosystems and languages, such as JavaScript, Swift, ObjectiveC and Android just to name a few.

The following shows example requests when interacting with a local deployment of Parse Server. If you deployed Parse Server remotely, change the URL accordingly.

REST API

Save object:

curl -X POST \
  -H "X-Parse-Application-Id: YOUR_APP_ID" \
  -H "Content-Type: application/json" \
  -d '{"score":1337}' \
  http://localhost:1337/parse/classes/GameScore

Call Cloud Code function:

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

JavaScript

// Initialize SDK
Parse.initialize("YOUR_APP_ID", "unused");
Parse.serverURL = 'http://localhost:1337/parse';

// Save object
const obj = new Parse.Object('GameScore');
obj.set('score',1337);
await obj.save();

// Query object
const query = new Parse.Query('GameScore');
const objAgain = await query.get(obj.id);

Android

// Initialize SDK in the application class
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
  .applicationId("YOUR_APP_ID")
  .server("http://localhost:1337/parse/")   // '/' important after 'parse'
  .build());

// Save object
ParseObject obj = new ParseObject("TestObject");
obj.put("foo", "bar");
obj.saveInBackground();

iOS / tvOS / iPadOS / macOS (Swift)

// Initialize SDK in AppDelegate
Parse.initializeWithConfiguration(ParseClientConfiguration(block: {
  (configuration: ParseMutableClientConfiguration) -> Void in
    configuration.server = "http://localhost:1337/parse/" // '/' important after 'parse'
    configuration.applicationId = "YOUR_APP_ID"
}))

You can change the server URL in all of the open-source SDKs, but we're releasing new builds which provide initialization time configuration of this property.