-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
45 lines (42 loc) · 1.43 KB
/
main.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
'use strict';
const ApplicationBuilder = require('./Framework/ApplicationBuilder');
const configuration = require('./config');
const {controllers, http, ws, dependencies: depPath} = require('./config');
const dependencies = require(depPath);
const {interfaces} = dependencies;
const HttpTransport = require('./Framework/Transport/http/HttpTransport');
const HttpEndpoint = require('./Framework/Services/Router/HttpEndpoint');
const WsTransport = require('./Framework/Transport/ws/WsTransport');
const WSEndpoint = require('./Framework/Services/Router/WSEndpoint');
(async () => {
try {
const applicationBuilder = new ApplicationBuilder()
.setConfigurations(configuration)
.setDependencies(dependencies);
await applicationBuilder.buildServices();
await applicationBuilder.build();
const httpTransport = applicationBuilder
.useTransport(HttpTransport, HttpEndpoint, {
router: interfaces.IRouter,
logger: interfaces.ILogger,
transport: http,
controllers,
})
.startListen();
const wsTransport = applicationBuilder
.useTransport(WsTransport, WSEndpoint, {
router: interfaces.IRouter,
logger: interfaces.ILogger,
transport: ws,
controllers: false,
})
.startListen();
//test
setTimeout(() => {
httpTransport.stopListen();
wsTransport.stopListen();
}, 5000);
} catch (err) {
console.dir(err);
}
})();