Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Example of Parse Server using the express framework.

License

NotificationsYou must be signed in to change notification settings

parse-community/parse-server-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

parse-repository-header


Build StatusSnyk Badgeauto-release

Join The ConversationBackers on Open CollectiveSponsors on Open CollectiveLicenseForumTwitter


This is an example project using theParse Server module on Express.

TheParse Server guide is a good place to get started. AnAPI reference andCloud Code guide are also available. If you're interested in developing for Parse Server, theDevelopment guide will help you get set up. All documentations for Parse Platform's server and its client SDKs are available atparseplatform.org.


Local Development

  1. Make sure you have a compatible Node.js version installed. Runnode --version to see your local Node.js version. Open thepackage.json file too see which version of Node.js this example repository requires at{ engines": { "node": "<NODE_VERSION>" } }. Note that there may be other Parse Server version available that support older or newer Node.js versions, see theParse Server compatibility table.
  2. Clone this repository and change directory to it.
  3. Runnpm install.
  4. Install a MongoDB database locally fromhttps://docs.mongodb.org/master/tutorial/install-mongodb-on-os-x.
  5. Runmongo to connect to your database, just to make sure it's working. Once you see a mongo prompt, exit withControl-D.
  6. Launch Parse Server withnpm start.
  7. By default the API route will use/parse as a base. You can change this by setting the environment variablePARSE_MOUNT, for example in the CLI run runexport PARSE_MOUNT=/app to set the path toapp.
  8. Your Parse Server is not running and is connected to your local database nameddev in which the data is stored that you manage via Parse Server.

Docker Deployment

You can also run Parse Server using Docker:

  1. Create a.env file with your configuration variables. For example:

    APP_ID=myAppIdMASTER_KEY=myMasterKeyDATABASE_URI=mongodb://localhost:27017/parsePORT=1337PARSE_MOUNT=/parse
  2. Run Docker with the following command, mounting volumes as needed:

    docker build -t parse-server.docker run -p 1337:1337 --env-file .env \  -v$(pwd)/logs:/usr/src/parse/logs \  -v$(pwd)/cloud:/usr/src/parse/cloud \  parse-server

This allows you to:

  • Use an environment file for configuration
  • Mount the logs directory to persist logs outside the container
  • Mount the cloud directory to access your Cloud Code files from the container

You can customize the mounted volumes based on your needs, such as mounting config files or other directories that require persistence or runtime modifications.

Helpful Scripts

These scripts can help you to develop your app for Parse Server:

  • npm run watch will start your Parse Server and restart if you make any changes.
  • npm run lint will check the linting of your cloud code, tests andindex.ts, as defined in.eslintrc.json.
  • npm run lint-fix will attempt fix the linting of your cloud code, tests andindex.ts.
  • npm run prettier will help improve the formatting and layout of your cloud code, tests andindex.ts, as defined in.prettierrc.
  • npm test will run all tests
  • npm run coverage will run tests and check coverage. Output is available in the/coverage folder.

Configuration

Configuration is located inconfig.ts.

Remote Deployment

Heroku

Deploy

Alternatively, to deploy manually:

  • Clone the repo and change directory to it
  • Log in with theHeroku Toolbelt and create an app:heroku create
  • Use themLab addon:heroku addons:create mongolab:sandbox --app YourAppName
  • By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, runheroku config:set PARSE_MOUNT=/1
  • Deploy it with:git push heroku master

AWS Elastic Beanstalk

Alternatively, deploy your local changes manually:

  • Clone the repo and change directory to it
  • Log in with theAWS Elastic Beanstalk CLI, select a region, and create an app:eb init
  • Create an environment and pass in MongoDB URI, App ID, and Master Key:eb create --envvars DATABASE_URI=<replace with URI>,APP_ID=<replace with Parse app ID>,MASTER_KEY=<replace with Parse master key>

Microsoft Azure App Service

Deploy to Azure

Detailed information is available here:

Google App Engine

  1. Clone the repo and change directory to it
  2. Create a project in theGoogle Cloud Platform Console.
  3. Enable billing for your project.
  4. Install theGoogle Cloud SDK.
  5. Setup a MongoDB server. You have a few options:
  6. Create a Google Compute Engine virtual machine withMongoDB pre-installed.
  7. UsemLab to create a free MongoDB deployment on Google Cloud Platform (only US-central).
  8. Modifyapp.yaml to update your environment variables.
  9. DeleteDockerfile
  10. Deploy it withgcloud preview app deploy

A detailed tutorial is available here:Running Parse server on Google App Engine

Scalingo

Deploy to Scalingo

Alternatively, to deploy manually:

  • Clone the repo and change directory to it
  • Log in with theScalingo CLI and create an app:scalingo create my-parse
  • Use theScalingo MongoDB addon:scalingo addons-add scalingo-mongodb free
  • Setup MongoDB connection string:scalingo env-set DATABASE_URI='$SCALINGO_MONGO_URL'
  • By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, runscalingo env-set PARSE_MOUNT=/1
  • Deploy it with:git push scalingo master

OpenShift Online (Next Gen)

  1. Register for a freeOpenShift Online (Next Gen) account
  2. Create a project in theOpenShift Online Console.
  3. Install theOpenShift CLI.
  4. Add the Parse Server template to your project:oc create -f https://raw.githubusercontent.com/ParsePlatform/parse-server-example/master/openshift.json
  5. Deploy Parse Server from the web console
  6. Open your project in theOpenShift Online Console:
  7. ClickAdd to Project from the top navigation
  8. Scroll down and selectNodeJS > Parse Server
  9. (Optionally) Update the Parse Server settings (parameters)
  10. ClickCreate

A detailed tutorial is available here:Running Parse Server on OpenShift Online (Next Gen)

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 SDKParse.initialize("YOUR_APP_ID","unused");Parse.serverURL='http://localhost:1337/parse';// Save objectconstobj=newParse.Object('GameScore');obj.set('score',1337);awaitobj.save();// Query objectconstquery=newParse.Query('GameScore');constobjAgain=awaitquery.get(obj.id);

Android

// Initialize SDK in the application classParse.initialize(newParse.Configuration.Builder(getApplicationContext())  .applicationId("YOUR_APP_ID")  .server("http://localhost:1337/parse/")// '/' important after 'parse'  .build());// Save objectParseObjectobj =newParseObject("TestObject");obj.put("foo","bar");obj.saveInBackground();

iOS / tvOS / iPadOS / macOS (Swift)

// Initialize SDK in AppDelegateParse.initializeWithConfiguration(ParseClientConfiguration(block:{(configuration:ParseMutableClientConfiguration)->Voidin    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.

About

Example of Parse Server using the express framework.

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  

Packages

No packages published

Contributors44


[8]ページ先頭

©2009-2025 Movatter.jp