forked from vesparny/morpheus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
morpheus.js
43 lines (36 loc) · 1.06 KB
/
morpheus.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
'use strict';
var expressLoader = require('./server/express-loader');
var LoggerFactory = require('./server/logger-factory');
var pkg = require('./package.json');
var config = require('./shared/config');
var loggerFactory = new LoggerFactory(config);
var servicesLoader = require('./server/services/');
function Morpheus() {
this.config = {};
this.services = {};
}
Morpheus.prototype.init = function() {
this.config = config;
//load services
this.services = servicesLoader(this.config);
};
Morpheus.prototype.logger = loggerFactory.create('morpheus');
Morpheus.prototype.getLogger = loggerFactory.create.bind(loggerFactory);
Morpheus.prototype.run = function(callback) {
var that = this;
var expressApp = expressLoader();
var params = {
config: that.config,
loggerFactory: loggerFactory,
version: pkg.version
};
expressApp.listen(that.config.port, that.config.ip, function() {
callback({
version: params.version,
port: that.config.port,
});
});
};
var morpheus = new Morpheus();
morpheus.init();
module.exports = morpheus;