forked from electerious/Ackee
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
45 lines (32 loc) · 1.08 KB
/
index.js
File metadata and controls
45 lines (32 loc) · 1.08 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
#!/usr/bin/env node
'use strict'
require('dotenv').config()
const server = require('./server')
const signale = require('./utils/signale')
const config = require('./utils/config')
const connect = require('./utils/connect')
const stripUrlAuth = require('./utils/stripUrlAuth')
if (config.dbUrl == null) {
signale.fatal('MongoDB connection URI missing in environment')
process.exit(1)
}
server.on('listening', () => signale.watch(`Listening on http://localhost:${ config.port }`))
server.on('error', (err) => signale.fatal(err))
signale.await(`Connecting to ${ stripUrlAuth(config.dbUrl) }`)
connect(config.dbUrl).then(() => {
signale.success(`Connected to ${ stripUrlAuth(config.dbUrl) }`)
signale.start(`Starting the server`)
server.listen(config.port)
if (config.isDevelopmentMode === true) {
signale.info('Development mode enabled')
}
if (config.isDemoMode === true) {
signale.info('Demo mode enabled')
}
if (!config.username && !config.password) {
signale.warn('disabling username/password based authentication')
}
}).catch((err) => {
signale.fatal(err)
process.exit(1)
})