added version number to build

This commit is contained in:
2026-02-23 16:11:23 +01:00
parent 4d00936719
commit 639aac68ca
5 changed files with 53 additions and 18 deletions

View File

@@ -7,18 +7,21 @@
#include "ShadowrunApi.hpp"
#include "databasepool.h"
#include "crow/compression.h"
#include "Application.hpp"
using namespace std;
int main() {
std::cout << "Launching " << Application::name() << " version: " << Application::version() << std::endl;
AppSettings::Settings settings = AppSettings::load();
crow::App<crow::CORSHandler> app;
// init cors
auto& cors = app.get_middleware<crow::CORSHandler>();
cors.global()
.headers("Content-Type", "Authorization")
.methods("GET"_method, "POST"_method, "PUT"_method, "DELETE"_method, "OPTIONS"_method)
.headers("Content-Type", "Authorization")
.methods("GET"_method, "POST"_method, "PUT"_method, "DELETE"_method, "OPTIONS"_method)
.allow_credentials()
.origin(settings.domain)
.max_age(86400);
@@ -26,22 +29,22 @@ int main() {
// create global database
dbpool = std::make_unique<DatabasePool>(settings.db_path);
if (!dbpool->init(std::thread::hardware_concurrency())){
CROW_LOG_ERROR << "Failed to create database at : " << settings.db_path;
return 1;
std::cerr << "Failed to create database at : " << settings.db_path << std::endl;
std::exit(1);
}
auto opt_isPortOpen = utils::isLocalPortOpen(settings.http_port);
if (opt_isPortOpen.has_value()){
if (opt_isPortOpen.value()){
CROW_LOG_ERROR << "Local port : " << settings.http_port << " is already open";
return 1;
std::cerr << "Local port : " << settings.http_port << " is already open" << std::endl;
std::exit(1);
}
}
else {
CROW_LOG_ERROR << "failed to check if local port is open : " << opt_isPortOpen.error();
return 1;
std::cerr << "failed to check if local port is open : " << opt_isPortOpen.error() << std::endl;
std::exit(1);
}
// Root route
CROW_ROUTE(app, "/")([&]() {
return utils::getFile(utils::build_dir / "index.html");
@@ -54,14 +57,14 @@ int main() {
shadowrun::initApi(app);
login::initLogin(app);
// asssets is not svelte generated
CROW_ROUTE(app, "/assets/<path>")
([&](const std::string& p) {
filesystem::path file_path = utils::assets_dir / p;
return utils::getFile(file_path);
});
// Catch-all route for static files and SPA fallback
CROW_ROUTE(app, "/<path>")
([&](const std::string& p) {