-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStartup.js
52 lines (50 loc) · 1.38 KB
/
Startup.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
const {ILogger, ISessionService, ISessionStorage, IRouter} = interfaces;
const {HttpEndpoint, WSEndpoint} = adapters;
(class Startup {
configureServices(services) {
services.addSingleton(ILogger, Logger);
// services.addSingleton('db', Database);
services.addSingleton(ISessionStorage, MemorySessionStorage);
services.addSingleton(ISessionService, Sessions);
services.addSingleton(IRouter, Router);
}
async configure({[ILogger]: logger, [IRouter]: router}) {
logger.info('Hello from Startup');
router
.registerEndpoint(
new HttpEndpoint({
method: 'GET',
url: '/SayHello',
handler: async ({connection}) => {
connection.send('Hello');
},
}),
)
.registerEndpoint(
new HttpEndpoint({
method: 'GET',
url: '/',
handler: async ({connection}) => {
connection.redirect('/test1');
},
}),
)
.registerEndpoint(
new HttpEndpoint({
method: 'PUT',
url: '/getSecretCode',
handler: async ({connection}) => {
connection.send('Secret Code');
},
}),
)
.registerEndpoint(
new WSEndpoint({
url: 'TEST',
handler: async ({connection, data}) => {
connection.send(data);
},
}),
);
}
});