-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathapp.js
67 lines (53 loc) · 1.25 KB
/
app.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
require("babel-register");
var redis = require("redis");
var async = require('async');
var config = require('config');
var routes = require('./server/routes');
var _ = require('lodash');
var path = require('path');
global.__CLIENT__ = false;
global.__SERVER__ = true;
var client = redis.createClient({
socket_keepalive: true
});
var deps = {
basedir: __dirname,
config: config,
routes: routes,
log: null,
server: null,
mongodb: null,
passport: null,
redis: client
};
deps.passport = require('./server/lib/core/passport')(deps);
require('./server/lib')(deps);
async.eachSeries([
'log',
'mongodb',
'app',
'nodemailer',
'agenda'
], function(item, done){
var fn = require('./server/lib/core/'+item)(deps);
if(_.isFunction(fn)){
fn(function (err, result) {
if(err) return done(err);
deps[item] = result;
done(null, result);
})
}else {
process.nextTick(function(){
deps[item] = fn;
done(null, fn);
});
}
}, function (err, results) {
if(err){
console.log(err);
process.exit(1);
}
deps.app.listen(3000, function () {
console.log('app running on: ', 3000);
});
});