-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
47 lines (40 loc) · 1.15 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
var log = require('hogger')('main')
const constants = require('./locals/constants')
const requirePath = require('./locals/require_path')
const fs = require('fs')
const path = require('path')
var app = {
config: require('./config'),
const: constants,
isAuthenticated: (req, res, next) => {
if (req.isAuthenticated()) {
if (req.user.status !== app.const.ACCOUNT_STATUS.ACTIVE) {
req.flash('error', `This account is currently ${app.const.ACCOUNT_STATUS.getName(req.user.status)}.`)
req.logout()
res.redirect('/account/login')
} else {
next()
}
} else {
req.flash('error', 'You must be logged in to access that')
res.redirect('/account/login')
}
}
}
try {
log.info('loading services...')
app.services = requirePath('./services')
log.info('bootstrapping services...')
for(var service in app.services) {
app.services[service] = app.services[service](app)
}
log.info('initializing services...')
for(var service in app.services) {
if (app.services[service].initialize)
app.services[service].initialize()
}
} catch(error) {
log.error(error)
throw error
}
log.info('ready')