Parse server to be used as a microservice endpoint
|
9 år sedan | |
---|---|---|
cloud | 9 år sedan | |
.gitignore | 9 år sedan | |
Dockerfile | 9 år sedan | |
README.md | 9 år sedan | |
app.json | 9 år sedan | |
index.js | 9 år sedan | |
jsconfig.json | 9 år sedan | |
package.json | 9 år sedan |
Example project using the parse-server module on Express.
Read the full server guide here: https://parse.com/docs/server/guide
node --version
npm install
mongo
to connect to your database, just to make sure it's working. Once you see a mongo prompt, exit with Control-Dnpm start
export PARSE_MOUNT=/1
before launching the server.heroku create
heroku addons:create mongolab:sandbox
heroku config:set PARSE_MOUNT=/1
git push heroku master
You can use the REST API, the JavaScript SDK, and any of our open-source SDKs:
Example request to a server running locally:
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:
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); });
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.