index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Example express application adding the parse-server module to expose Parse
  2. // compatible API routes.
  3. var express = require('express');
  4. var ParseServer = require('parse-server').ParseServer;
  5. var path = require('path');
  6. var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
  7. if (!databaseUri) {
  8. console.log('DATABASE_URI not specified, falling back to localhost.');
  9. }
  10. var api = new ParseServer({
  11. //databaseURI: databaseUri || 'mongodb://localhost:27017/qrs',
  12. databaseURI: 'mongodb://'+process.env.MONGO_USER+':'+process.env.MONGO_PASWORD+'@localhost:27017/qrs' || 'mongodb://localhost:27017/qrs',
  13. cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  14. appId: process.env.APPLICATION_ID_QRS || 'myAppId',
  15. masterKey: process.env.MASTER_KEY_QRX || '', //Add your master key here. Keep it secret!
  16. serverURL: process.env.SERVER_URL || 'http://localhost:1337/parse', // Don't forget to change to https if needed
  17. liveQuery: {
  18. classNames: ["Posts", "Comments"] // List of classes to support for query subscriptions
  19. }
  20. });
  21. console.log(databaseURI);
  22. console.log(process.env.MASTER_KEY_QRX);
  23. console.log(process.env.SERVER_URL);
  24. // Client-keys like the javascript key or the .NET key are not necessary with parse-server
  25. // If you wish you require them, you can set them as options in the initialization above:
  26. // javascriptKey, restAPIKey, dotNetKey, clientKey
  27. var app = express();
  28. // Serve static assets from the /public folder
  29. app.use('/public', express.static(path.join(__dirname, '/public')));
  30. // Serve the Parse API on the /parse URL prefix
  31. var mountPath = process.env.PARSE_MOUNT || '/parse';
  32. app.use(mountPath, api);
  33. // Parse Server plays nicely with the rest of your web routes
  34. app.get('/', function(req, res) {
  35. res.status(200).send('I dream of being a website. Please star the parse-server repo on GitHub!');
  36. });
  37. // There will be a test page available on the /test path of your server url
  38. // Remove this before launching your app
  39. app.get('/test', function(req, res) {
  40. res.sendFile(path.join(__dirname, '/public/test.html'));
  41. });
  42. var port = process.env.PORT || 1337;
  43. var httpServer = require('http').createServer(app);
  44. httpServer.listen(port, function() {
  45. console.log('parse-server-example running on port ' + port + '.');
  46. });
  47. // This will enable the Live Query real-time server
  48. ParseServer.createLiveQueryServer(httpServer);