@@ -16,35 +16,41 @@ var api = new ParseServer({
1616 cloud : process . env . CLOUD_CODE_MAIN || __dirname + '/cloud/main.js' ,
1717 appId : process . env . APP_ID || 'myAppId' ,
1818 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+ }
2023} ) ;
2124// Client-keys like the javascript key or the .NET key are not necessary with parse-server
2225// If you wish you require them, you can set them as options in the initialization above:
2326// javascriptKey, restAPIKey, dotNetKey, clientKey
2427
2528var app = express ( ) ;
2629
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' ) ) ) ;
2932
3033// Serve the Parse API on the /parse URL prefix
3134var mountPath = process . env . PARSE_MOUNT || '/parse' ;
3235app . use ( mountPath , api ) ;
3336
3437// Parse Server plays nicely with the rest of your web routes
3538app . 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! ' ) ;
3740} ) ;
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'));
4241
42+ // There will be a test page available on the /test path of your server url
43+ // Remove this before launching your app
4344app . get ( '/test' , function ( req , res ) {
4445 res . sendFile ( path . join ( __dirname , '/public/test.html' ) ) ;
4546} ) ;
4647
4748var port = process . env . PORT || 1337 ;
48- app . listen ( port , function ( ) {
49+ var httpServer = require ( 'http' ) . createServer ( app ) ;
50+ httpServer . listen ( port , function ( ) {
4951 console . log ( 'parse-server-example running on port ' + port + '.' ) ;
5052} ) ;
53+
54+ // This will enable the Live Query real-time server
55+ ParseServer . createLiveQueryServer ( httpServer ) ;
56+
0 commit comments