{"id":19000689,"url":"https://github.com/flaviomarcio/qapr","last_synced_at":"2026-05-15T13:31:40.693Z","repository":{"id":209546383,"uuid":"415737183","full_name":"flaviomarcio/qapr","owner":"flaviomarcio","description":"Qt-QApr, application runnable made in Qt/C++ to support backend and mobile app development. ","archived":false,"fork":false,"pushed_at":"2023-11-15T16:25:26.000Z","size":326,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-18T23:12:45.130Z","etag":null,"topics":["cpp","qt","rest-api","services","settings"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flaviomarcio.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2021-10-11T00:58:25.000Z","updated_at":"2023-11-27T22:17:04.000Z","dependencies_parsed_at":"2023-11-28T00:27:03.775Z","dependency_job_id":"ae2cc9a6-bbce-494b-bb21-b44e620b87e1","html_url":"https://github.com/flaviomarcio/qapr","commit_stats":null,"previous_names":["flaviomarcio/qapr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/flaviomarcio/qapr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviomarcio%2Fqapr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviomarcio%2Fqapr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviomarcio%2Fqapr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviomarcio%2Fqapr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flaviomarcio","download_url":"https://codeload.github.com/flaviomarcio/qapr/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flaviomarcio%2Fqapr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33068360,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp","qt","rest-api","services","settings"],"created_at":"2024-11-08T18:08:09.192Z","updated_at":"2026-05-15T13:31:40.677Z","avatar_url":"https://github.com/flaviomarcio.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# QApr\n\n**Application runnable, control suite with Orm and WebServer using QOrm and QRpc.**\n\n\n## Working architecture\n\u003e##Support QRpc\n\u003e## Support\n\u003e\u003e## Request\n\u003e```\n\u003eHTTP/REST, LocalSocket, TCP, UPD, WebSocket \n\u003e```\n\u003e\u003e## Streaming\n\u003e```\n\u003e Brokers Database, AMQP, MQTT, KAFKA\n\u003e```\n\u003e## Support QOrm\n\u003e```\n\u003e ANSI, MySQL, SQlite, Oracle, Postgres-PSQL, SQLServer-TSQL\n\u003e```\n\n## Prerequisits\n\u003e```bash\n\u003e mkdir myproject;\n\u003e cd myproject;\n\u003e git clone git@github.com:flaviomarcio/qstm.git;\n\u003e git clone git@github.com:flaviomarcio/qrpc.git;\n\u003e git clone git@github.com:flaviomarcio/qorm.git;\n\u003e git clone git@github.com:flaviomarcio/qapr.git;\n\u003e```\n\u003eCheck example in QApr/example/application\n\n\n## CMake Build information\n\n\u003e```\n\u003e## initial CMake parameters \n\u003e\n\u003e-GNinja\n\u003e-DCMAKE_BUILD_TYPE:STRING=Debug\n\u003e-DCMAKE_PROJECT_INCLUDE_BEFORE:PATH=%{IDE:ResourcePath}/package-manager/auto-setup.cmake\n\u003e-DQT_QMAKE_EXECUTABLE:STRING=%{Qt:qmakeExecutable}\n\u003e-DCMAKE_PREFIX_PATH:STRING=%{Qt:QT_INSTALL_PREFIX}\n\u003e-DCMAKE_C_COMPILER:STRING=%{Compiler:Executable:C}\n\u003e-DCMAKE_CXX_COMPILER:STRING=%{Compiler:Executable:Cxx}\n\u003e-DCMAKE_INSTALL_PREFIX=~/build/myproject/install/Debug\n\u003e```\n\n\u003e```bash\n\u003e cd qapr\n\u003e mkdir build;\n\u003e cd build;\n\u003e cmake ..;\n\u003e make;\n\u003e make install;\n\u003e```\n\n## QMake Build information\n\n\u003e```bash\n\u003e cd qapr\n\u003e qmake qapr.pro\n\u003e make;\n\u003e make install;\n\u003e ls -l;\n\u003e```\n\n## Configure QMake project\n\n\u003e```c++\n\u003eCONFIG += c++17\n\u003eCONFIG += console\n\u003eCONFIG += silent\n\u003eQT += gui core\n\u003e\n\u003eTEMPLATE = app\n\u003eTARGET = demo\n\u003e\n\u003einclude($$PWD/../../../qstm/qstm.pri)\n\u003einclude($$PWD/../../../qrpc/qrpc.pri)\n\u003einclude($$PWD/../../../qorm/qorm.pri)\n\u003einclude($$PWD/../../qapr/qapr.pri)\n\u003e\n\u003eHEADERS += \\\n\u003e    $$PWD/controllerMethods.h \\\n\u003e    $$PWD/personModel.h \\\n\u003e    $$PWD/personController.h\n\u003e\n\u003eSOURCES += \\\n\u003e     $$PWD/controllerMethods.cpp \\\n\u003e    $$PWD/personController.cpp \\\n\u003e    $$PWD/main.cpp\n\u003e\n\u003eRESOURCES += \\\n\u003e    $$PWD/settings.qrc\n\u003e```\n\n## Resource settings for QRpc/QOrm\n\u003eSettings for webservers and connection database server saved in setting.json and included in settings.qrc\n\u003e```json\n\u003e{\n\u003e   \"arguments\":[\"ws\"],\n\u003e   \"protocol\":{\n\u003e      \"default\":{\n\u003e         \"minThreads\":1,\n\u003e         \"maxThreads\":2000,\n\u003e         \"cleanupInterval\":1000,\n\u003e         \"readTimeout\":60000,\n\u003e         \"maxRequestSize\":104857600,\n\u003e         \"maxMultiPartSize\":1048576000,\n\u003e         \"enabled\":false,\n\u003e         \"sslKeyFile\":\"\",\n\u003e         \"sslCertFile\":\"\"\n\u003e      },\n\u003e      \"http\":{\n\u003e        \"enabled\":true,\"port\":[8888]\n\u003e      }\n\u003e   },\n\u003e   \"connection\":{\n\u003e       \"secret\": \"YzUxNDFhMDA5\",\n\u003e       \"enviroment\" : \"debug\",\n\u003e       \"paramaters\" : {\n\u003e           \"debug\":{\n\u003e               \"driver\":\"QPSQL\",\n\u003e               \"hostName\":\"localhost\",\n\u003e               \"userName\":\"localuser\",\n\u003e               \"password\":\"localuser\",\n\u003e               \"port\":5432,\n\u003e               \"dataBaseName\":\"postgres\",\n\u003e               \"schemaNames\":\"public\"\n\u003e           }\n\u003e       }\n\u003e   }\n\u003e}\n\u003e```\n\n\n## Using QRpc\n\u003e## Implementation main.cpp\n\u003eCheck example in QApr/example/application\n\u003e```c++\n\u003e//main implementation\n\u003e\n\u003e#include \u003cQApr\u003e\n\u003e\n\u003eQAPR_MAIN_DECLARE()\n\u003e```\n\u003e## Webservices methods implementation\n\u003eCheck example in QApr/example/application\n\u003e\n\u003e```c++\n\u003e#include \u003cQRpc/Server\u003e\n\u003e\n\u003e//!\n\u003e//! \\brief The ControllerMethods class\n\u003e//!\n\u003e//! inhetihed of QRpc::QRPCController\n\u003eclass ControllerMethods : public QRpc::QRPCController\n\u003e{\n\u003e    Q_OBJECT\n\u003epublic:\n\u003e    //!\n\u003e    //! \\brief ControllerMethods\n\u003e    //! \\param parent\n\u003e    //!\n\u003e    //! necessary Q_INVOKABLE\n\u003e    Q_INVOKABLE explicit ControllerMethods(QObject *parent = nullptr);\n\u003e\n\u003e    //!\n\u003e    //! \\brief authorization\n\u003e    //! \\return\n\u003e    //!\n\u003e    //! authorization validations\n\u003e    //! check more authorization methods:\n\u003e    //!     canAuthorization\n\u003e    //!     beforeAuthorization\n\u003e    //!     afterAuthorization\n\u003e    //!\n\u003e    virtual bool authorization();\n\u003e\n\u003e    //!\n\u003e    //! \\brief listObjects\n\u003e    //! \\return\n\u003e    //!\n\u003e    //! method to return object list, necessary Q_INVOKABLE\n\u003e    //! check more Invoke methods:\n\u003e    //!     requestBeforeInvoke\n\u003e    //!     requestAfterInvoke\n\u003e    Q_INVOKABLE QVariant listObjects();\n\u003e\n\u003e};\n\u003e\n\u003e//auto register interface\n\u003eQRPC_CONTROLLER_AUTO_REGISTER(ControllerMethods)   \n\u003e```\n\u003e## Example of request\n\u003eCheck example in QRpc/example/server-rest\n\u003e```bash\n\u003e curl -i http://localhost:8888/listObjects?limit=1\n\u003e ```\n\u003e```bash\n\u003eHTTP/1.1 200 (OK)\n\u003eVary: Accept-Encoding, Origin\n\u003eDate: Sat Jan 15 18:50:02 2022\n\u003eContent-Length: 59\n\u003eServer: Undef\n\u003e```\n\u003e\n\u003e```json\n\u003e[{\"index\":1,\"uuid\":\"ba01138f-f7b0-4874-a879-caa591ab9e55\"}]\n\u003e```\n\n## Using QOrm\n\u003e## Implementation PersonModel Mapper\n\u003eCheck example in QApr/example/application\n\u003e\n\u003e```c++\n\u003e#include \u003cQOrm\u003e\n\u003e//!\n\u003e//! \\brief The PersonModel class\n\u003e//! \n\u003e//! inherits of QOrm::Model\n\u003eclass PersonModel : public QOrm::Model\n\u003e{\n\u003e    Q_OBJECT\n\u003epublic:\n\u003e    QORM_MODEL(PersonModel)//make default methods for PersonModel\n\u003e    QORM_DECLARE_MODEL_DESCRIPTION(tr(\"Person\"))//description\n\u003e    QORM_DECLARE_TABLE_SCHEMA()//declare schema name in database\n\u003e    QORM_DECLARE_TABLE(tab000,_,person)//table in database\n\u003e    QORM_DECLARE_TABLE_PRIMARY_KEY(uuid)//inform PK name\n\u003e    QORM_DECLARE_TABLE_FOREIGN_KEY(parent_uuid)//declare FK\n\u003e    QORM_DESCRIPTOR_ORDERBY(name)//declare default order by\n\u003epublic:\n\u003e    QORM_DECLARE_PROPERTY(QUuid  , uuid         , uuidGenerator()   )//declare field and default value\n\u003e    QORM_DECLARE_PROPERTY(QDate  , dt_record    , QDate()           )//declare field and default value\n\u003e    QORM_DECLARE_PROPERTY(QUuid  , parent_uuid  , QUuid()           )//declare field and default value\n\u003e    QORM_DECLARE_PROPERTY(QString, name         , QString()         )//declare field and default value\n\u003e    QORM_DECLARE_PROPERTY(bool   , enabled      , false             )//declare field and default value\n\u003epublic:\n\u003e    QORM_MODEL_CONSTRUCTOR(PersonModel, QOrm::Model)//contructors for PersonModel\n\u003e};\n\u003e\n\u003e//REGISTER MODEL AND DECLARE CRUD AND DAO\n\u003eQORM_DECLARE_CRUD(PersonModel)\n\u003e```\n\n\u003e## Implementation PersonController\n\u003eCheck example in QApr/example/application\n\u003e\n\u003e```c++\n\u003e#include \u003cQOrm\u003e\n\u003e\n\u003e//!\n\u003e//! \\brief The PersonController class\n\u003e//!\n\u003e//! inherits of QOrm::Controller\n\u003eclass PersonController : public QOrm::Controller\n\u003e{\n\u003e    Q_OBJECT\n\u003epublic:\n\u003e    //!\n\u003e    //! \\brief personController\n\u003e    //! \\param parent\n\u003e    //!\n\u003e    //! constructor controller to pass current connection\n\u003e    QORM_CONTROLLER_CONSTRUCTOR(PersonController)\n\u003e\n\u003e    //!\n\u003e    //! \\brief crud\n\u003e    //! \\param vBody\n\u003e    //! \\return\n\u003e    //! example of CRUD\n\u003e    ResultValue \u0026crud(const QVariant \u0026vBody);\n\u003e\n\u003e    .....more\n\u003e\n\u003e};\n\u003e```\n\n\u003e## Using QOrm::ModelDao\n\u003eCheck example in QApr/example/application\n\u003e## Using CRUD methods\n\u003e\n\u003e```c++\n\u003eResultValue \u0026PersonController::crud(const QVariant \u0026vBody)\n\u003e{\n\u003e    //Person CRUD\n\u003e    PersonModelCRUD crud(vBody, this);\n\u003e    return this-\u003elr(crud.crudify());//return success/error and created object\n\u003e}\n\u003e```\n\u003e## Using  upsert/insert/update/remove methods\n\u003e\n\u003e```c++\n\u003eResultValue \u0026PersonController::upsert(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e    PersonModel model(v);\n\u003e\n\u003e    //insert or update record\n\u003e    if(!dao.upsert(model))\n\u003e        return this-\u003elr();//return error\n\u003e\n\u003e    return this-\u003elr(model.toHash());//return success and created object\n\u003e}\n\u003e\n\u003eResultValue \u0026PersonController::insert(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e\n\u003e    //remove record\n\u003e    return this-\u003elr(dao.insert(v));//return successful/error\n\u003e}\n\u003e\n\u003eResultValue \u0026PersonController::update(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e\n\u003e    //remove record\n\u003e    return this-\u003elr(dao.update(v));//return successful/error\n\u003e}\n\u003e\n\u003eResultValue \u0026PersonController::remove(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e\n\u003e    //remove record\n\u003e    return this-\u003elr(dao.remove(v));//return successful/error\n\u003e}\n\u003e```\n\u003e## Using record/recordList methods\n\u003e```c++\n\u003eResultValue \u0026PersonController::record(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e\n\u003e    //get record\n\u003e    return this-\u003elr(dao.record(v));//return success/error and record\n\u003e}\n\u003e\n\u003eResultValue \u0026PersonController::recordList(const QVariant \u0026v)\n\u003e{\n\u003e    //Person generic dao\n\u003e    PersonModelGDao dao(this);\n\u003e\n\u003e    //get record\n\u003e    return this-\u003elr(dao.recordList(v));//return success/error and record\n\u003e}\n\u003e```\n\u003e\n\u003e## Using  query buider strategy\n\u003e```c++\n\u003eResultValue \u0026PersonController::listPerson(const QVariant \u0026v)\n\u003e{\n\u003e    QOrm::Query query(this);\n\u003e\n\u003e    auto\u0026select=query.builder().select();\n\u003e\n\u003e    select\n\u003e        .fields(PersonModelR)\n\u003e        .from(PersonModelR);\n\u003e\n\u003e    select\n\u003e        .where()\n\u003e        .equal(PersonModelM.parent_uuid_field(), v);\n\u003e\n\u003e    //execute query\n\u003e    if(!query.exec())\n\u003e        return this-\u003elr();//return error\n\u003e\n\u003e    //make record list\n\u003e    return this-\u003elr(query.makeRecordList());//return successful and record list\n\u003e}\n\u003e\n\u003eResultValue \u0026PersonController::listPersonParent(const QVariant \u0026v)\n\u003e{\n\u003e    QOrm::Query query(this);\n\u003e\n\u003e    auto\u0026select=query.builder().select();\n\u003e\n\u003e    select\n\u003e        .fields()\n\u003e        .f(PersonModelM.uuid_field(\"a\"))\n\u003e        .f(PersonModelM.parent_uuid_field(\"a\"))\n\u003e        .f(PersonModelM.name_field(\"a\"))\n\u003e        .f(PersonModelM.enabled_field(\"a\"));\n\u003e    select\n\u003e        .from(PersonModelR, \"a\");\n\u003e\n\u003e    select\n\u003e        .joinInner(PersonModelR).alias(\"b\")\n\u003e        .equal(PersonModelM.parent_uuid_field(\"b\"), PersonModelM.parent_uuid_field(\"a\"));\n\u003e\n\u003e    select\n\u003e        .where()\n\u003e        .equal(PersonModelM.parent_uuid_field(\"a\"), v);\n\u003e\n\u003e    //execute query\n\u003e    if(!query.exec())\n\u003e        return this-\u003elr();//return error\n\u003e\n\u003e    //make record list\n\u003e    return this-\u003elr(query.makeRecordList());//return successful and record list\n\u003e}\n\u003e```\n\u003e\n\u003e## Using  multi tasks execute\n\u003e```c++\n\u003eResultValue \u0026PersonController::runMultiTasks()\n\u003e{\n\u003e    //lamba to async update record\n\u003e\n\u003e    auto errorUpdateDate=[](QSqlDatabase\u0026, const QVariant\u0026)\n\u003e    {\n\u003e        qWarning()\u003c\u003c\"It\\'s not OK\";\n\u003e        //..action to error\n\u003e        return QVariant();\n\u003e    };\n\u003e\n\u003e    auto successUpdateDate=[](QSqlDatabase\u0026, const QVariant\u0026)\n\u003e    {\n\u003e        qWarning()\u003c\u003c\"it\\'s OK\";\n\u003e        //..action to success\n\u003e        return QVariant();\n\u003e    };\n\u003e\n\u003e    auto executeUpdateDate=[](QSqlDatabase\u0026connection, const QVariant\u0026record){\n\u003e        //Person generic dao\n\u003e        PersonModelGDao dao;\n\u003e        dao.setConnection(connection);//individual connection to task\n\u003e        PersonModel model(record);//load body model\n\u003e        model.set_dt_record(QDate::currentDate());//update dt\n\u003e\n\u003e        if(!dao.upsert(model))//insert/update person\n\u003e            return dao.lr().toHash();//record body error\n\u003e\n\u003e        return model.toHash();//return new body object\n\u003e    };\n\u003e\n\u003e    PersonModelGDao dao(this);//dao to current connection\n\u003e    auto vList=dao.recordList().resultToList();//list all personModel record\n\u003e\n\u003e    QOrm::TaskRunner taskRunner(this);//task runner controller\n\u003e    taskRunner\n\u003e        .slotCount(QThread::idealThreadCount())//maximum thread in actual machine\n\u003e        .values(vList)//personModel records\n\u003e        .onExecute(executeUpdateDate)//lambda to async execute\n\u003e        .onFailed(errorUpdateDate)//lambda to error notify\n\u003e        .onSuccess(successUpdateDate)//lambda to success notify\n\u003e        .start();//wait to finish\n\u003e\n\u003e    return this-\u003elr(taskRunner.lr());//return successful/error\n\u003e\n\u003e}\n\u003e```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviomarcio%2Fqapr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflaviomarcio%2Fqapr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflaviomarcio%2Fqapr/lists"}