Преглед изворни кода

Updating to use latest parse-server and parse sdk for Live Query launch

Fosco Marotto пре 9 година
родитељ
комит
c5240dd44e
2 измењених фајлова са 18 додато и 12 уклоњено
  1. 15 9
      index.js
  2. 3 3
      package.json

+ 15 - 9
index.js

@@ -16,7 +16,10 @@ var api = new ParseServer({
   cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
   appId: process.env.APP_ID || 'myAppId',
   masterKey: process.env.MASTER_KEY || '', //Add your master key here. Keep it secret!
-  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse'  // Don't forget to change to https if needed
+  serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse',  // Don't forget to change to https if needed
+  liveQuery: {
+    classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
+  }
 });
 // Client-keys like the javascript key or the .NET key are not necessary with parse-server
 // If you wish you require them, you can set them as options in the initialization above:
@@ -24,8 +27,8 @@ var api = new ParseServer({
 
 var app = express();
 
-// Config static middleware for assets
-app.use('/static', express.static(path.join(__dirname, '/public')));
+// Serve static assets from the /public folder
+app.use('/public', express.static(path.join(__dirname, '/public')));
 
 // Serve the Parse API on the /parse URL prefix
 var mountPath = process.env.PARSE_MOUNT || '/parse';
@@ -33,18 +36,21 @@ app.use(mountPath, api);
 
 // Parse Server plays nicely with the rest of your web routes
 app.get('/', function(req, res) {
-  res.status(200).send('I dream of being a web site.');
+  res.status(200).send('Make sure to star the parse-server repo on GitHub!');
 });
- // If you are migrating a webapp hosted on domain.parseapp.com:
- // Remove statement above serving the 200 status (app.get('/ function()});
- // Uncomment app.use below and set the absolute path for serving files in the /public dir
- // app.use(express.static(__dirname + '/public'));
 
+// There will be a test page available on the /test path of your server url
+// Remove this before launching your app
 app.get('/test', function(req, res) {
   res.sendFile(path.join(__dirname, '/public/test.html'));
 });
 
 var port = process.env.PORT || 1337;
-app.listen(port, function() {
+var httpServer = require('http').createServer(app);
+httpServer.listen(port, function() {
     console.log('parse-server-example running on port ' + port + '.');
 });
+
+// This will enable the Live Query real-time server
+ParseServer.createLiveQueryServer(httpServer);
+

+ 3 - 3
package.json

@@ -1,6 +1,6 @@
 {
   "name": "parse-server-example",
-  "version": "1.3.0",
+  "version": "1.4.0",
   "description": "An example Parse API server using the parse-server module",
   "main": "index.js",
   "repository": {
@@ -11,8 +11,8 @@
   "dependencies": {
     "express": "~4.11.x",
     "kerberos": "~0.0.x",
-    "parse": "~1.6.12",
-    "parse-server": "~2.1.6"
+    "parse": "~1.8.0",
+    "parse-server": "~2.2.0"
   },
   "scripts": {
     "start": "node index.js"