-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathapp.js
54 lines (35 loc) · 1.14 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
// # app
var path = require('path');
var IoC = require('electrolyte');
var bootable = require('bootable');
var express = require('express');
// change the working directory to the root directory
process.chdir(__dirname);
// dependency injection
IoC.loader(IoC.node(path.join(__dirname, 'boot')));
IoC.loader('igloo', require('igloo'));
IoC.loader('controllers', IoC.node(path.join(__dirname, 'app', 'controllers')));
IoC.loader('models', IoC.node(path.join(__dirname, 'app', 'models')));
// phases
var app = bootable(express());
// removing this since it seems we still get errors
// <https://github.com/yeoman/update-notifier/issues/25#issuecomment-52824043>
//app.phase(IoC.create('igloo/update-notifier'))
app.phase(bootable.di.initializers());
app.phase(bootable.di.routes());
app.phase(IoC.create('igloo/server'));
// boot
var logger = IoC.create('igloo/logger');
var settings = IoC.create('igloo/settings');
app.boot(function(err) {
if (err) {
logger.error(err.message);
if (settings.showStack) {
logger.error(err.stack);
}
process.exit(-1);
return;
}
logger.info('app booted');
});
exports = module.exports = app;