-
Notifications
You must be signed in to change notification settings - Fork 118
/
server.js
30 lines (23 loc) · 954 Bytes
/
server.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
'use strict'
const AV = require('leanengine')
AV.init({
appId: process.env.LEANCLOUD_APP_ID,
appKey: process.env.LEANCLOUD_APP_KEY,
masterKey: process.env.LEANCLOUD_APP_MASTER_KEY
})
// Comment the following line if you do not want to use masterKey.
AV.Cloud.useMasterKey()
const app = require('./app')
// Retrieves the port number from environment variable `LEANCLOUD_APP_PORT`.
// LeanEngine runtime will assign a port and set the environment variable automatically.
const PORT = parseInt(process.env.LEANCLOUD_APP_PORT || process.env.PORT || 3000)
app.listen(PORT, (err) => {
console.log('Node app is running on port:', PORT)
// Registers a global exception handler for uncaught exceptions.
process.on('uncaughtException', err => {
console.error('Caught exception:', err.stack)
});
process.on('unhandledRejection', (reason, p) => {
console.error('Unhandled Rejection at: Promise ', p, ' reason: ', reason.stack)
})
})