-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
49 lines (35 loc) · 1.75 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
var path = require('path');
var express = require('express');
var ParseServer = require('parse-server').ParseServer;
var databaseUri = process.env.DATABASE_URI || process.env.MONGODB_URI;
databaseUri || console.log('DATABASE_URI not specified, falling back to localhost.');
var port = process.env.PORT || 1337;
var api = new ParseServer(
{
databaseURI: databaseUri || 'mongodb://localhost:27017/dev',
appId : process.env.APP_ID || 'myAppId',
masterKey : process.env.MASTER_KEY || 'masterKey', //Add your master key here. Keep it secret!
serverURL : process.env.SERVER_URL || 'http://localhost:' + port + '/1',
// If you change the cloud/main.js to another path
// it wouldn't work on SashiDo :( ... so Don't change this.
cloud : process.env.CLOUD_CODE_MAIN || 'cloud/main.js',
liveQuery:
{
classNames: [] // List of classes to support for query subscriptions example: [ 'Posts', 'Comments' ]
},
});
// Client-keys like the javascript key or the .NET key are not necessary with parse-server
// If you wish you require them, you can set them as options in the initialization above:
// javascriptKey, restAPIKey, dotNetKey, clientKey
var app = express();
// Serve static assets from the /public folder
app.use(express.static(path.join(__dirname, '/public')));
// Mount your cloud express app
app.use('/', require('./cloud/main.js').app);
// Serve the Parse API on the /parse URL prefix
var mountPath = process.env.PARSE_MOUNT || '/1';
app.use(mountPath, api);
var httpServer = require('http').createServer(app);
httpServer.listen(port, function(){ console.log('Running on http://localhost:' + port); });
// This will enable the Live Query real-time server
ParseServer.createLiveQueryServer(httpServer);