-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathweb.js
More file actions
45 lines (37 loc) · 1.3 KB
/
web.js
File metadata and controls
45 lines (37 loc) · 1.3 KB
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
/**
* Created by kras on 10.11.16.
*/
const express = require('express');
const ejsLocals = require('ejs-locals');
const di = require('core/di');
const {load} = require('core/i18n');
const config = require('./config');
const moduleName = require('./module-name');
const dispatcher = require('./controllers/dispatcher');
const wsdl = require('./controllers/wsdl');
const extendDi = require('core/extendModuleDi');
const path = require('path');
const alias = require('core/scope-alias');
const errorSetup = require('core/error-setup');
errorSetup(path.join(__dirname, 'strings'));
const app = module.exports = express(); // eslint-disable-line
app.get(`/${moduleName}/:service.wsdl`, wsdl);
app.post(`/${moduleName}/:service`, dispatcher);
app.engine('ejs', ejsLocals);
app.set('views', path.join(__dirname, '/tpl'));
app.set('view engine', 'ejs');
app._init = function() {
/**
* @type {{settings: SettingsRepository, auth: Auth, sessionHandler: SessionHandler}}
*/
const rootScope = di.context('app');
rootScope.auth.exclude(`/${moduleName}/**`);
rootScope.sessionHandler.exclude(`/${moduleName}/**`);
return di(moduleName,
extendDi(moduleName, config.di),
{module: app},
'app',
[],
`modules/${moduleName}`)
.then(scope => alias(scope, scope.settings.get(`${moduleName}.di-alias`)));
};