-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
39 lines (32 loc) · 1.32 KB
/
main.cpp
File metadata and controls
39 lines (32 loc) · 1.32 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
#include <iostream>
#include <memory>
#include <stdexcept>
#include "auth/AuthManager.hpp"
#include "configs/StartupConfig.hpp"
#include "parsers/ParsersFactory.hpp"
#include "servers/Server.hpp"
#include "services/TaxServiceFactory.hpp"
#include "storage/StorageFactory.hpp"
int main(int argc, char* argv[]) {
try {
if (const auto config = optionsToStartupConfig(argc, argv)) {
std::cout << "Starting server on port " << config->port << '\n';
const auth::AuthManager authManager;
const parsers::ParsersFactory parsersFactory(config->report_format);
const storage::StorageFactory storageFactory(
config->storage_format);
const auto credentialsParser =
parsersFactory.createCredentialsParser();
const auto reportParser = parsersFactory.createReportParser();
const auto reportStorage = storageFactory.createReportStorage();
const services::TaxServiceFactory taxServiceFactory(
authManager, *reportParser, *reportStorage);
servers::runServer(config->port, authManager, *credentialsParser,
taxServiceFactory);
}
} catch (std::exception& e) {
std::cerr << __FILE__ << ' ' << e.what() << '\n';
return 1;
}
return 0;
}