From 53f266cbee2e9b76dff69fd62b6296a95c37d5d6 Mon Sep 17 00:00:00 2001 From: snider Date: Thu, 16 Oct 2025 17:06:57 +0100 Subject: [PATCH] renames ApiCoreInfoComponent to ApiCoreInfo and updates references in ApiServer --- src/api/ApiServer.cpp | 19 ++++++++++++++----- ...iCoreInfoComponent.hpp => ApiCoreInfo.hpp} | 10 +++++----- 2 files changed, 19 insertions(+), 10 deletions(-) rename src/api/controller/{ApiCoreInfoComponent.hpp => ApiCoreInfo.hpp} (84%) diff --git a/src/api/ApiServer.cpp b/src/api/ApiServer.cpp index fbfd8ad7..53067d99 100644 --- a/src/api/ApiServer.cpp +++ b/src/api/ApiServer.cpp @@ -13,15 +13,15 @@ // #include "ApiServer.hpp" -#include "controller/ApiCoreInfoComponent.hpp" +#include "controller/ApiCoreInfo.hpp" #include "controller/path/info.hpp" #include "controller/path/block.hpp" #include "controller/path/block/hash.hpp" #include "controller/path/block/id.hpp" +#include "controller/path/info/version.hpp" #include "oatpp/network/Server.hpp" #include "oatpp-swagger/Controller.hpp" - #include #include "version.h" #include "common/command_line.h" @@ -55,9 +55,9 @@ void ApiServer::run() { /* Register Components in scope of run() method */ Components components; - OATPP_CREATE_COMPONENT(std::shared_ptr, coreInfoComponent) + OATPP_CREATE_COMPONENT(std::shared_ptr, coreInfoComponent) ([this] { - return std::make_shared(*m_ccore, *m_p2p, *m_rpc_server); + return std::make_shared(*m_ccore, *m_p2p, *m_rpc_server); }()); /* Get router component */ @@ -65,11 +65,20 @@ void ApiServer::run() { auto docEndpoints = std::make_shared(); - /* Create and register controllers */ + /* + * Create and register controllers, this list will get VERY large, but, it has to be this way as oatpp creates a + * static routing file before compile time, can't dynamically add controllers, or, be smart AND also have project code awareness + * by this list being large, it allows for per endpoint code separation; + * any PR that tries to reduce this, MUST have unit tests to prove it works, no exceptions. + */ auto infoController = std::make_shared(); docEndpoints->append(infoController->getEndpoints()); router->addController(infoController); + auto infoVersionController = std::make_shared(); + docEndpoints->append(infoVersionController->getEndpoints()); + router->addController(infoVersionController); + auto blockController = std::make_shared(); docEndpoints->append(blockController->getEndpoints()); router->addController(blockController); diff --git a/src/api/controller/ApiCoreInfoComponent.hpp b/src/api/controller/ApiCoreInfo.hpp similarity index 84% rename from src/api/controller/ApiCoreInfoComponent.hpp rename to src/api/controller/ApiCoreInfo.hpp index 7946b263..9754ff6d 100644 --- a/src/api/controller/ApiCoreInfoComponent.hpp +++ b/src/api/controller/ApiCoreInfo.hpp @@ -12,8 +12,8 @@ // SPDX‑License‑Identifier: EUPL-1.2 // -#ifndef ApiCoreInfoComponent_hpp -#define ApiCoreInfoComponent_hpp +#ifndef ApiCoreInfo_hpp +#define ApiCoreInfo_hpp #include "currency_core/currency_core.h" #include "p2p/net_node.h" @@ -24,14 +24,14 @@ typedef nodetool::node_server> p2psrv_t; // A simple holder for core blockchain components that can be injected into controllers. -class ApiCoreInfoComponent { +class ApiCoreInfo { private: currency::core& m_core; p2psrv_t& m_p2p; currency::core_rpc_server& m_rpc_server; public: - ApiCoreInfoComponent(currency::core& core, p2psrv_t& p2p, currency::core_rpc_server& rpc_server) + ApiCoreInfo(currency::core& core, p2psrv_t& p2p, currency::core_rpc_server& rpc_server) : m_core(core), m_p2p(p2p), m_rpc_server(rpc_server) {} @@ -40,4 +40,4 @@ public: currency::core_rpc_server& getRpcServer() { return m_rpc_server; } }; -#endif /* ApiCoreInfoComponent_hpp */ +#endif /* ApiCoreInfo_hpp */