1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- // Example express application adding the parse-server module to expose Parse
- // compatible API routes.
- var express = require('express');
- var ParseServer = require('parse-server').ParseServer;
- var path = require('path');
- var databaseUri = process.env.PARSE_QRS_URL || process.env.MONGODB_URI;
- if (!databaseUri) {
- console.log('DATABASE_URI not specified, falling back to localhost.');
- }
- var api = new ParseServer({
- databaseURI: databaseUri || 'mongodb://localhost:27017/qrs',
- cloud: process.env.CLOUD_CODE_MAIN || __dirname + '/cloud/main.js',
- appId: process.env.APPLICATION_ID_QRS || 'myAppId',
- masterKey: process.env.MASTER_KEY_QRS || '', //Add your master key here. Keep it secret!
- serverURL: process.env.SERVER_URL_PARSE_QRS || '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
- }
- });
- var app = express();
- // 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';
- app.use(mountPath, api);
- // Parse Server plays nicely with the rest of your web routes
- app.get('/', function(req, res) {
- res.status(200).send("It's alive!!");
- });
- // 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.PARSE_PORT || 1337;
- 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);
|