index.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  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. if (!process.env.DATABASE_URI) {
  6. console.log('DATABASE_URI not specified, falling back to localhost.');
  7. }
  8. var api = new ParseServer({
  9. databaseURI: process.env.DATABASE_URI || 'mongodb://localhost:27017/dev',
  10. cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
  11. appId: process.env.APP_ID || 'myAppId',
  12. masterKey: process.env.MASTER_KEY || 'myMasterKey'
  13. });
  14. // Client-keys like the javascript key or the .NET key are not necessary with parse-server
  15. // If you wish you require them, you can set them as options in the initialization above:
  16. // javascriptKey, restAPIKey, dotNetKey, clientKey
  17. var app = express();
  18. // Serve the Parse API on the /parse URL prefix
  19. var mountPath = process.env.PARSE_MOUNT || '/parse';
  20. app.use(mountPath, api);
  21. // Parse Server plays nicely with the rest of your web routes
  22. app.get('/', function(req, res) {
  23. res.status(200).send('I dream of being a web site.');
  24. });
  25. var port = process.env.PORT || 1337;
  26. app.listen(port, function() {
  27. console.log('parse-server-example running on port ' + port + '.');
  28. });