Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Parse Server

Drew
June 08, 2016

Parse Server

A talk I gave at NSMeetup about Parse Server

Drew

June 08, 2016
Tweet

Other Decks in Programming

Transcript

  1. WHAT IS PARSE? Parse SDKs Parse Server Parse Dashboard A

    note on security Parse Live Queries
  2. import Parse Parse.initializeWithConfiguration(ParseClientConfiguration { $0.applicationId = "my-app" $0.server = "https://my-site.com/parse"

    }) let nsMeetup = PFObject(className: "Meetup") nsMeetup["name"] = "NSMeetup" nsMeetup["date"] = NSDate() nsMeetup["location"] = PFGeoPoint(latitude: 40.0, longitude: -30.0) nsMeetup.saveInBackgroundWithBlock { (success: Bool, error: NSError?) -> Void in if (success) { // The object has been saved. } }
  3. let query = PFQuery(className: "Meetup") query.whereKey("name", equalTo: "NSMeetup") query.whereKey("date", greaterThan:

    NSDate()) query.whereKey("location", nearGeoPoint: /* ... */) query.orderByAscending("date") query.findObjectsInBackgroundWithBlock { (objects: [PFObject]?, error: NSError?) -> Void in if error == nil { // The find succeeded. } }
  4. RUN IT ON YOUR LAPTOP $ npm install -g parse-server

    mongodb-runner $ mongodb-runner start $ parse-server --appId yourAppId --masterKey yourMasterKey parse-server running on http://localhost:1337/parse
  5. ADD IT TO EXPRESS var app = express(); var api

    = new ParseServer({ databaseURI: 'mongodb://localhost:27017/meetupsParseApp', appId: 'yourAppId', masterKey: 'yourMasterKey', cloud: './cloud.js', serverURL: 'http://localhost:1337/parse', }); app.use('/parse', api); app.use('/dashboard', new ParseDashboard({ ... })); app.listen(1337);
  6. var api = new ParseServer({ databaseURI: 'mongodb://localhost:27017/meetupsParseApp', appId: 'yourAppId', masterKey:

    'yourMasterKey', cloud: './cloud.js', serverURL: 'http://localhost:1337/parse', verifyUserEmails: true, publicServerURL: 'http://my-site.com/parse', emailAdapter: { module: 'parse-server-simple-mailgun-adapter', options: { fromAddress: '[email protected]', domain: 'mailgun-domain', apiKey: 'mailgun-key', } } });
  7. PARSE DASHBOARD $ npm install -g parse-dashboard $ parse-dashboard --appId

    yourAppId --masterKey yourMasterKey --serverURL "https://meetup-app.com/parse" The dashboard is now available at http://0.0.0.0:4040/ OR var express = require('express'); var ParseDashboard = require('parse-dashboard'); var app = express(); var dashboard = new ParseDashboard({ serverURL: "...", appId: "...", masterKey: "...", }); app.use('/dashboard', dashboard); app.listen(4040);
  8. SERVER SETUP let api = new ParseServer({ ..., liveQuery: {

    classNames: ['Test', 'TestAgain'] } }); let httpServer = require('http').createServer(app); httpServer.listen(port); let parseLiveQueryServer = ParseServer.createLiveQueryServer(httpServer);