forked from democracy-os-fr/democracyos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
32 lines (28 loc) · 763 Bytes
/
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
const debug = require('debug')
const config = require('lib/config')
const server = require('lib/server')
const checkNodeVersion = require('lib/check-node-version')
const migrations = require('lib/migrations')
const models = require('lib/models')()
const log = debug('democracyos:root')
// Basic server configuration
const opts = {
port: process.env.PORT || config.publicPort,
protocol: config.protocol,
https: config.https
}
if (module === require.main) {
checkNodeVersion()
.then(models.ready())
.then(migrations.ready())
.then(() => {
server(opts, function (err) {
if (err) throw err
log('DemocracyOS server running...')
})
})
.catch((err) => {
console.error(err)
process.exit(1)
})
}