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