-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
86 lines (70 loc) · 3.19 KB
/
app.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
require("dotenv").config();
const Server = require("./src/Server");
const ConfigurationService = require("./src/services/ConfigurationService.js");
const AuthenticationService = require("./src/services/AuthenticationService");
const MongooseClient = require("./src/clients/MongooseClient");
const UsersRepository = require("./src/database/User/UsersRepository");
const VouchersRepository = require("./src/database/Voucher/VouchersRepository");
const VoucherSuppliesRepository = require("./src/database/VoucherSupply/VoucherSuppliesRepository");
const PaymentsRepository = require("./src/database/Payment/PaymentsRepository");
const EventRepository = require("./src/database/Event/EventsRepository");
const AdministratorAuthenticationMiddleware = require("./src/api/middlewares/AdministratorAuthenticationMiddleware");
const UserAuthenticationMiddleware = require("./src/api/middlewares/UserAuthenticationMiddleware");
const UsersModule = require("./src/modules/UsersModule");
const VoucherSuppliesModule = require("./src/modules/VoucherSuppliesModule");
const VouchersModule = require("./src/modules/VouchersModule");
const PaymentsModule = require("./src/modules/PaymentsModule");
const EventsModule = require("./src/modules/EventsModule");
const AdministrationModule = require("./src/modules/AdministrationModule");
const HealthModule = require("./src/modules/HealthModule");
const configurationService = new ConfigurationService();
const authenticationService = new AuthenticationService(
configurationService.tokenSecret
);
const mongooseClient = new MongooseClient(
configurationService.databaseConnectionString,
configurationService.databaseName,
configurationService.databaseUsername,
configurationService.databasePassword
);
const usersRepository = new UsersRepository();
const vouchersRepository = new VouchersRepository();
const voucherSuppliesRepository = new VoucherSuppliesRepository();
const paymentsRepository = new PaymentsRepository();
const eventsRepository = new EventRepository();
const administratorAuthenticationMiddleware = new AdministratorAuthenticationMiddleware(
authenticationService,
usersRepository
);
const userAuthenticationMiddleware = new UserAuthenticationMiddleware(
configurationService.gcloudSecret,
authenticationService
);
const dependencies = {
configurationService,
authenticationService,
usersRepository,
vouchersRepository,
voucherSuppliesRepository,
paymentsRepository,
eventsRepository,
administratorAuthenticationMiddleware,
userAuthenticationMiddleware,
};
const healthModule = new HealthModule(dependencies);
const usersModule = new UsersModule(dependencies);
const voucherSuppliesModule = new VoucherSuppliesModule(dependencies);
const vouchersModule = new VouchersModule(dependencies);
const paymentsModule = new PaymentsModule(dependencies);
const eventsModule = new EventsModule(dependencies);
const administrationModule = new AdministrationModule(dependencies);
new Server()
.withMongooseClient(mongooseClient)
.withModule(healthModule)
.withModule(usersModule)
.withModule(voucherSuppliesModule)
.withModule(vouchersModule)
.withModule(paymentsModule)
.withModule(eventsModule)
.withModule(administrationModule)
.start(process.env.PORT || 3000);