igloo.js
868 Bytes
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
// # Igloo
var async = require('async')
var config = require('./config')
var schemas = require('./schemas')
var lib = require('./lib')(config)
var app = require('./config/app')
module.exports = igloo
function igloo(callback) {
async.parallel({
db: lib.mongo,
sessions: lib.redis
}, loadConnections)
function loadConnections(err, connections) {
if (err) return callback(err)
lib.db = connections.db
lib.config.session.store = lib.sessions = connections.sessions
schemas(lib, loadSchemas)
}
function loadSchemas(err, lib) {
if (err) return callback(err)
app(lib, callback)
}
}
if (!module.parent)
igloo(function(err, app) {
if (err) return lib.logger.error(err)
app.listen(config.port, function() {
lib.logger.info('igloo started at %s://%s:%d', config.protocol, config.host, config.port)
})
})