forked from linagora/linagora.esn.group
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
91 lines (72 loc) · 3.36 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
'use strict';
const AwesomeModule = require('awesome-module');
const Dependency = AwesomeModule.AwesomeModuleDependency;
const path = require('path');
const glob = require('glob-all');
const FRONTEND_JS_PATH = __dirname + '/frontend/app/';
const MODULE_NAME = 'group';
const AWESOME_MODULE_NAME = 'linagora.esn.' + MODULE_NAME;
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.availability', 'availability'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.db', 'db'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.collaboration', 'collaboration'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.user', 'user'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.domain', 'domain'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.tuple', 'tuple'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.i18n', 'i18n'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.pubsub', 'pubsub'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.elasticsearch', 'elasticsearch'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.people', 'people'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.models', 'core-models'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.authorization', 'authorizationMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.helper', 'helperMW'),
new Dependency(Dependency.TYPE_NAME, 'linagora.esn.core.webserver.middleware.domain', 'domainMW')
],
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);
// Register every exposed frontend scripts
const frontendJsFilesFullPath = glob.sync([
FRONTEND_JS_PATH + '**/*.module.js',
FRONTEND_JS_PATH + '**/!(*spec).js'
]);
const frontendJsFilesUri = frontendJsFilesFullPath.map(function(filepath) {
return filepath.replace(FRONTEND_JS_PATH, '');
});
webserverWrapper.injectAngularAppModules(MODULE_NAME, frontendJsFilesUri, AWESOME_MODULE_NAME, ['esn'], {
localJsFiles: frontendJsFilesFullPath
});
const lessFile = path.join(FRONTEND_JS_PATH, 'app.less');
webserverWrapper.injectLess(MODULE_NAME, [lessFile], 'esn');
webserverWrapper.addApp(MODULE_NAME, app);
return callback();
},
start: function(dependencies, callback) {
this.lib.init();
callback();
}
}
});
/**
* The main AwesomeModule describing the application.
* @type {AwesomeModule}
*/
module.exports = myAwesomeModule;