-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
57 lines (48 loc) · 1.39 KB
/
Copy pathindex.js
File metadata and controls
57 lines (48 loc) · 1.39 KB
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
50
51
52
53
54
55
56
57
var express = require('express')
var ParseServer = require('parse-server').ParseServer
var ParseDashboard = require("parse-dashboard")
var fs = require('fs')
var app = express()
var config = require("./env.js")
var api = new ParseServer({
databaseURI: config.databaseURI,
cloud: config.cloudDir,
appId: config.appId,
masterKey: config.masterKey,
serverURL: config.serverURL + ':' + config.port + config.mountPath,
liveQuery: { classNames: config.liveQueryClassNames }
})
var dashboard = new ParseDashboard({
apps: [{
serverURL: config.serverURL + ':' + config.port + config.mountPath,
appId: config.appId,
masterKey: config.masterKey,
appName: config.appName
}],
users: config.users
}, true);
var mountPath = config.mountPath
app.use(mountPath, api)
var dashPath = config.dashPath
app.use(dashPath, dashboard)
app.get('/', function (req, res) {
if(config.redirect){
res.redirect(config.redirect)
} else {
res.status(200).send('Server is Live!')
}
})
var port = config.port
if(config.pfx){
var options = {
pfx: fs.readFileSync(config.pfx),
passphrase: config.passphrase
}
var httpServer = require('https').createServer(options, app)
} else {
var httpServer = require('http').createServer(app)
}
httpServer.listen(port, function () {
console.log('parse-server running on port ' + port + '.')
})
ParseServer.createLiveQueryServer(httpServer)