forked from BloomBooks/bloom-parse-server
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix instance.save() calls * Allow debugging with vscode * Make temp users unique * When debugging, give a master_key * Replace generic readme with actual instructions * Add cloud code function for testing connection to db * typos
- Loading branch information
Showing
3 changed files
with
123 additions
and
148 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Launch Server", | ||
"type": "node", | ||
"request": "launch", | ||
"cwd": "${workspaceRoot}", | ||
"runtimeExecutable": "node", | ||
"runtimeArgs": [ | ||
"--debug=5858", "index.js" | ||
], | ||
"port": 5858, | ||
"env": { | ||
"MASTER_KEY": "123" | ||
//can use the following to use with a remote mongodb, else you get the local one | ||
//,"DATABASE_URI": "mongodb://<path to mongo db with credentials" | ||
} | ||
}, | ||
{ | ||
"name": "Attach to running Server", | ||
"type": "node", | ||
"request": "attach", | ||
"port": 5858, | ||
"address": "localhost", | ||
"restart": false, | ||
"sourceMaps": false, | ||
"outFiles": [], | ||
"localRoot": "${workspaceRoot}", | ||
"remoteRoot": null | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,148 +1,63 @@ | ||
# parse-server-example | ||
# bloom-parse-server | ||
|
||
Example project using the [parse-server](https://github.com/ParsePlatform/parse-server) module on Express. | ||
This is the database backend for bloom-library.org, using the [parse-server](https://github.com/ParsePlatform/parse-server) module on Express. | ||
|
||
Read the full Parse Server guide here: https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide | ||
Here is the full [Parse Server guide](https://github.com/ParsePlatform/parse-server/wiki/Parse-Server-Guide). | ||
|
||
### For Local Development | ||
### Set Up For Local Development | ||
|
||
* Make sure you have at least Node 4.3. `node --version` | ||
* Clone this repo and change directory to it. | ||
* `npm install` | ||
* Install mongo locally using http://docs.mongodb.org/master/tutorial/install-mongodb-on-os-x/ | ||
* Run `mongo` to connect to your database, just to make sure it's working. Once you see a mongo prompt, exit with Control-D | ||
* Run the server with: `npm start` | ||
* By default it will use a path of /parse for the API routes. To change this, or use older client SDKs, run `export PARSE_MOUNT=/1` before launching the server. | ||
* You now have a database named "dev" that contains your Parse data | ||
* Install ngrok and you can test with devices | ||
1. Make sure you have at least Node 4.3. | ||
|
||
### Getting Started With Heroku + mLab Development | ||
`node --version` | ||
1. Clone this repo and go into its directory, and install or update the dependencies: | ||
|
||
#### With the Heroku Button | ||
`npm install` | ||
|
||
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy) | ||
1. Install mongodb server | ||
|
||
#### Without It | ||
1. Give mongodb a blank directory to work with, and run it: | ||
|
||
* Clone the repo and change directory to it | ||
* Log in with the [Heroku Toolbelt](https://toolbelt.heroku.com/) and create an app: `heroku create` | ||
* Use the [mLab addon](https://elements.heroku.com/addons/mongolab): `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, run `heroku config:set PARSE_MOUNT=/1` | ||
* Deploy it with: `git push heroku master` | ||
`c:\Program Files\MongoDB\Server\3.2\bin>mongod.exe --dbpath x:\temp\mongodata` | ||
|
||
### Getting Started With AWS Elastic Beanstalk | ||
1. Start up this server: | ||
|
||
#### With the Deploy to AWS Button | ||
`npm start` | ||
|
||
<a title="Deploy to AWS" href="https://console.aws.amazon.com/elasticbeanstalk/home?region=us-west-2#/newApplication?applicationName=ParseServer&solutionStackName=Node.js&tierName=WebServer&sourceBundleUrl=https://s3.amazonaws.com/elasticbeanstalk-samples-us-east-1/eb-parse-server-sample/parse-server-example.zip" target="_blank"><img src="http://d0.awsstatic.com/product-marketing/Elastic%20Beanstalk/deploy-to-aws.png" height="40"></a> | ||
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. | ||
|
||
#### Without It | ||
To verify that it is running, open a browser to http://localhost:1337/test | ||
|
||
* Clone the repo and change directory to it | ||
* Log in with the [AWS Elastic Beanstalk CLI](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb-cli3-install.html), 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>` | ||
1. Run Parse Dashboard: | ||
|
||
### Getting Started With Microsoft Azure App Service | ||
``` | ||
npm install parse-dashboard --global | ||
parse-dashboard --appId myAppId --masterKey "123" --serverURL | ||
``` | ||
#### With the Deploy to Azure Button | ||
This will say it is available at http://0.0.0.0, but actually it is at http://localhost. | ||
[![Deploy to Azure](http://azuredeploy.net/deploybutton.png)](https://azuredeploy.net/) | ||
1. Setup or update the mongodb Schema | ||
#### Without It | ||
``` | ||
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 | ||
A detailed tutorial is available here: | ||
[Azure welcomes Parse developers](https://azure.microsoft.com/en-us/blog/azure-welcomes-parse-developers/) | ||
`{"result":"SetupTables ran to completion."}` | ||
and see the tables in the dashboard. | ||
### Getting Started With Google App Engine | ||
1. Clone the repo and change directory to it | ||
1. Create a project in the [Google Cloud Platform Console](https://console.cloud.google.com/). | ||
1. [Enable billing](https://console.cloud.google.com/project/_/settings) for your project. | ||
1. Install the [Google Cloud SDK](https://cloud.google.com/sdk/). | ||
1. Setup a MongoDB server. You have a few options: | ||
1. Create a Google Compute Engine virtual machine with [MongoDB pre-installed](https://cloud.google.com/launcher/?q=mongodb). | ||
1. Use [MongoLab](https://mongolab.com/google/) to create a free MongoDB deployment on Google Cloud Platform. | ||
1. Modify `app.yaml` to update your environment variables. | ||
1. Delete `Dockerfile` | ||
1. Deploy it with `gcloud preview app deploy` | ||
### Cloud Code | ||
A detailed tutorial is available here: | ||
[Running Parse server on Google App Engine](https://cloud.google.com/nodejs/resources/frameworks/parse-server) | ||
Normally you will only touch the "cloud code", found in cloud/main.js. | ||
### Getting Started With Scalingo | ||
### Sample Queries | ||
#### With the Scalingo button | ||
|
||
[![Deploy to Scalingo](https://cdn.scalingo.com/deploy/button.svg)](https://my.scalingo.com/deploy) | ||
|
||
#### Without it | ||
|
||
* Clone the repo and change directory to it | ||
* Log in with the [Scalingo CLI](http://cli.scalingo.com/) and create an app: `scalingo create my-parse` | ||
* Use the [Scalingo MongoDB addon](https://scalingo.com/addons/scalingo-mongodb): `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, run `scalingo env-set PARSE_MOUNT=/1` | ||
* Deploy it with: `git push scalingo master` | ||
|
||
# Using it | ||
|
||
Before using it, you can access a test page to verify if the basic setup is working fine [http://localhost:1337/test](http://localhost:1337/test). | ||
Then you can use the REST API, the JavaScript SDK, and any of our open-source SDKs: | ||
|
||
Example request to a server running locally: | ||
|
||
```curl | ||
curl -X POST \ | ||
-H "X-Parse-Application-Id: myAppId" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \ | ||
http://localhost:1337/parse/classes/GameScore | ||
``` | ||
curl -X POST \ | ||
-H "X-Parse-Application-Id: myAppId" \ | ||
-H "Content-Type: application/json" \ | ||
-d '{}' \ | ||
http://localhost:1337/parse/functions/hello | ||
``` | ||
|
||
Example using it via JavaScript: | ||
|
||
```javascript | ||
Parse.initialize('myAppId','unused'); | ||
Parse.serverURL = 'https://whatever.herokuapp.com'; | ||
|
||
var obj = new Parse.Object('GameScore'); | ||
obj.set('score',1337); | ||
obj.save().then(function(obj) { | ||
console.log(obj.toJSON()); | ||
var query = new Parse.Query('GameScore'); | ||
query.get(obj.id).then(function(objAgain) { | ||
console.log(objAgain.toJSON()); | ||
}, function(err) {console.log(err); }); | ||
}, function(err) { console.log(err); }); | ||
``` | ||
|
||
Example using it on Android: | ||
```java | ||
//in your application class | ||
|
||
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext()) | ||
.applicationId("myAppId") | ||
.server("http://myServerUrl/parse/") // '/' important after 'parse' | ||
.build()); | ||
|
||
ParseObject testObject = new ParseObject("TestObject"); | ||
testObject.put("foo", "bar"); | ||
testObject.saveInBackground(); | ||
``` | ||
Example using it on iOS (Swift): | ||
```swift | ||
//in your AppDelegate | ||
|
||
Parse.initializeWithConfiguration(ParseClientConfiguration(block: { (configuration: ParseMutableClientConfiguration) -> Void in | ||
configuration.server = "https://<# Your Server URL #>/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. |
Oops, something went wrong.