-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
76 lines (62 loc) · 3.03 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
'use strict';
const AwesomeModule = require('awesome-module');
const Dependency = AwesomeModule.AwesomeModuleDependency;
const MODULE_NAME = 'smartsla';
const AWESOME_MODULE_NAME = `${MODULE_NAME}-backend`;
const myAwesomeModule = new AwesomeModule(AWESOME_MODULE_NAME, {
dependencies: [
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.logger', 'logger'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.wrapper', 'webserver-wrapper'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.db', 'db'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.user', 'coreUser'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.domain', 'coreDomain'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.collaboration', 'collaboration'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.elasticsearch', 'coreElasticsearch'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.esn-config', 'esn-config'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.email', 'email'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.pubsub', 'pubsub'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.authorization', 'authorizationMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.domain', 'domainMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.helper', 'helperMw'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.denormalize.user', 'coreUserDenormalizer'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.i18n', 'i18n'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.filestore', 'filestore'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.activitystreams', 'activitystreams'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.wsserver', 'wsserver'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.availability', 'availability')
],
states: {
lib: function(dependencies, callback) {
const moduleLib = require('./backend/lib')(dependencies);
const module = require('./backend/webserver/api')(dependencies, moduleLib);
const lib = {
api: {
module: module
},
lib: moduleLib
};
return callback(null, lib);
},
deploy: function(dependencies, callback) {
const webserverWrapper = dependencies('webserver-wrapper');
// Register the webapp
const app = require('./backend/webserver/application')(dependencies, this);
// Register every exposed endpoints
app.use('/api', this.api.module);
webserverWrapper.addApp('ticketing', app);
return callback();
},
start: function(dependencies, callback) {
require('./backend/ws')(dependencies).init();
this.lib.start(callback);
}
}
});
module.exports = Object.freeze({
name: AWESOME_MODULE_NAME
});
/**
* The main AwesomeModule describing the application.
* @type {AwesomeModule}
*/
module.exports = myAwesomeModule;