-
Notifications
You must be signed in to change notification settings - Fork 0
build(architecture): #55: synchronization to align with the architectural patterns of the inner-circle-items-api repository #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
JDRkow
wants to merge
14
commits into
master
Choose a base branch
from
feature/#55-synchronization-to-align-with-the-architectural-patterns-of-the-inner-circle-items-api-repository
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
e2fdd50
chore(architecture): #55: create core level of architecture
JDRkow ce5c2c5
chore(architecture): #55: move out alembic functional
JDRkow 05c0225
chore(architecture): #55: create application level of architecture
JDRkow 98389b3
chore(architecture): #55: create api level of architecture
JDRkow 2c0705a
chore(architecture): #55: revrite cmakefile due new architecture
JDRkow 5bc8be9
fix(architecture): #55: add compiler flags for api
JDRkow 0da52a3
chore(architecture): #55: add warn for future unit tests implementation
JDRkow d23a7b7
ref(architecture): #55: add a variables for library names and cleanup…
JDRkow 141503e
Merge branch 'master' into feature/#55-synchronization-to-align-with-…
JDRkow 1381d9e
chore: #55: complete merge conflicts
JDRkow bcdebe5
style: #55: run auto-format
JDRkow 6ae7916
chore: #55: complete merge conflicts with controller
JDRkow e0338c4
fix(config): #55: add app-config to main cmake
JDRkow a215e5f
fix(config): #55: add drogon to application cmake due app config depe…
JDRkow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| file(GLOB_RECURSE api_sources | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp | ||
| ) | ||
|
|
||
| add_library(${API_LIB} STATIC ${api_sources}) | ||
|
|
||
| target_include_directories(${API_LIB} PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ) | ||
|
|
||
| target_link_libraries(${API_LIB} | ||
| PUBLIC ${APPLICATION_LIB} | ||
| Drogon::Drogon | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| #pragma once | ||
|
|
||
| #include <drogon/HttpController.h> | ||
|
|
||
| #include "features/create-to-do/create-to-do-handler.h" | ||
| #include "features/get-all-to-dos/get-all-to-dos-handler.h" | ||
| #include "features/get-to-do-by-id/get-to-do-by-id-handler.h" | ||
| #include "features/hard-delete-to-do/hard-delete-to-do-handler.h" | ||
| #include "features/soft-delete-to-do/soft-delete-to-do-handler.h" | ||
|
|
||
| using namespace drogon; | ||
|
|
||
| class ToDosController : public drogon::HttpController<ToDosController> | ||
| { | ||
| public: | ||
| explicit ToDosController(); | ||
|
|
||
| METHOD_LIST_BEGIN | ||
| ADD_METHOD_TO(ToDosController::getToDos, "/api/to-dos", Get); // Getting a list of tasks | ||
| ADD_METHOD_TO(ToDosController::addToDo, "/api/to-dos", Post); // Adding a new task | ||
| ADD_METHOD_TO(ToDosController::completeToDos, "/api/to-dos/complete", Post); // Executing (deleting) a task list | ||
| ADD_METHOD_TO(ToDosController::deleteToDo, "/api/to-dos", Delete); // Deleting a specific task | ||
| METHOD_LIST_END | ||
|
|
||
| HttpResponsePtr createInternalServerErrorResponse(const std::string& error) const; | ||
|
|
||
| void getToDos(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback); | ||
|
|
||
| void addToDo(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback); | ||
|
|
||
| void completeToDos(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback); | ||
|
|
||
| void deleteToDo(const HttpRequestPtr& req, std::function<void(const HttpResponsePtr&)>&& callback); | ||
|
|
||
| private: | ||
| std::shared_ptr<odb::database> db_; | ||
|
|
||
| std::unique_ptr<CreateToDoCommand> createToDoCommand_; | ||
| std::unique_ptr<GetAllToDosQuery> getAllToDosQuery_; | ||
| std::unique_ptr<GetToDoById> getToDoByIdQuery_; | ||
| std::unique_ptr<HardDeleteToDoCommand> hardDeleteToDoCommand_; | ||
| std::unique_ptr<SoftDeleteCommand> softDeleteCommand_; | ||
|
|
||
| std::unique_ptr<CreateToDoHandler> createToDoHandler_; | ||
| std::unique_ptr<GetAllToDosHandler> getAllToDosHandler_; | ||
| std::unique_ptr<GetToDoByIdHandler> getToDoByIdHandler_; | ||
| std::unique_ptr<HardDeleteToDoHandler> hardDeleteToDoHandler_; | ||
| std::unique_ptr<SoftDeleteToDoHandler> softDeleteToDoHandler_; | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| file(GLOB_RECURSE application_sources | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/odb-gen/*.cxx | ||
| ) | ||
|
|
||
| add_library(${APPLICATION_LIB} STATIC ${application_sources}) | ||
|
|
||
| target_include_directories(${APPLICATION_LIB} PUBLIC | ||
| ${CMAKE_CURRENT_SOURCE_DIR} | ||
| ${CMAKE_CURRENT_SOURCE_DIR}/odb-gen | ||
| ) | ||
|
|
||
| target_link_libraries(${APPLICATION_LIB} | ||
| PUBLIC ${CORE_LIB} | ||
| JsonCpp::JsonCpp | ||
| PRIVATE libodb::libodb | ||
| libodb-pgsql::libodb-pgsql | ||
| Drogon::Drogon | ||
| ) |
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions
14
src/application/features/create-to-do/create-to-do-command.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include "create-to-do-command.h" | ||
| #include "odb-gen/to-do-odb.hxx" | ||
| #include <odb/transaction.hxx> | ||
|
|
||
| uint64_t CreateToDoCommand::execute(const std::string& name, std::time_t createdAtUtc) | ||
| { | ||
| ToDo todo(name, createdAtUtc); | ||
|
|
||
| odb::transaction t(db_.begin()); | ||
| db_.persist(todo); | ||
| t.commit(); | ||
|
|
||
| return todo.id(); | ||
| } |
18 changes: 18 additions & 0 deletions
18
src/application/features/create-to-do/create-to-do-command.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| #pragma once | ||
|
|
||
| #include "to-do.h" | ||
| #include <memory> | ||
| #include <odb/database.hxx> | ||
|
|
||
| class CreateToDoCommand | ||
| { | ||
| public: | ||
| CreateToDoCommand(odb::database& db) | ||
| : db_(db) | ||
| {} | ||
|
|
||
| uint64_t execute(const std::string& name, std::time_t createdAtUtc); | ||
|
|
||
| private: | ||
| odb::database& db_; | ||
| }; |
13 changes: 13 additions & 0 deletions
13
src/application/features/create-to-do/create-to-do-handler.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #include "create-to-do-handler.h" | ||
| #include <chrono> | ||
| #include <ctime> | ||
|
|
||
| using std::string; | ||
|
|
||
| CreateToDoResponse CreateToDoHandler::handle(const CreateToDoRequest& request) | ||
| { | ||
| const std::time_t now_utc = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()); | ||
|
|
||
| const uint64_t id = _createToDoCommand.execute(request.name, now_utc); | ||
| return { id }; | ||
| } |
17 changes: 17 additions & 0 deletions
17
src/application/features/create-to-do/create-to-do-handler.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| #pragma once | ||
| #include "create-to-do-command.h" | ||
| #include "create-to-do-request.h" | ||
| #include "create-to-do-response.h" | ||
|
|
||
| class CreateToDoHandler | ||
| { | ||
| private: | ||
| CreateToDoCommand& _createToDoCommand; | ||
|
|
||
| public: | ||
| explicit CreateToDoHandler(CreateToDoCommand& createToDoCommand) | ||
| : _createToDoCommand(createToDoCommand) | ||
| {} | ||
|
|
||
| CreateToDoResponse handle(const CreateToDoRequest& request); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #pragma once | ||
| #include <string> | ||
|
|
||
| struct CreateToDoRequest | ||
| { | ||
| std::string name; | ||
| }; |
7 changes: 7 additions & 0 deletions
7
src/application/features/create-to-do/create-to-do-response.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| #pragma once | ||
| #include <cstdint> | ||
|
|
||
| struct CreateToDoResponse | ||
| { | ||
| uint64_t id; | ||
| }; | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems uint64_t is used from stdint.h, not cstdint. I suggest using std::uint64_t.