Skip to content

Commit

Permalink
-
Browse files Browse the repository at this point in the history
  • Loading branch information
sabudilovskiy committed Oct 20, 2023
1 parent d795a55 commit afbc373
Show file tree
Hide file tree
Showing 33 changed files with 265 additions and 749 deletions.
52 changes: 37 additions & 15 deletions .gen/objs.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
src/views/test-openapi-view/view.hpp
src/views/test-openapi-view/view.cpp
src/views/test-openapi-view/declarations.hpp
src/views/register/view.hpp
src/views/register/view.cpp
src/views/register/declarations.hpp
src/views/login/view.hpp
src/views/login/view.cpp
src/views/login/declarations.hpp
src/utils/type_holder.hpp
src/utils/tests_macros.hpp
src/utils/shared_transaction.hpp
src/utils/serialize/uuid/string.hpp
src/utils/serialize/uuid/string.cpp
src/utils/postgres_helper.hpp
src/utils/pg_controller.hpp
src/utils/perform_common_errors.hpp
src/utils/perform_common_errors.cpp
src/utils/parse/uuid/string.hpp
src/utils/parse/uuid/string.cpp
src/utils/meta.hpp
src/utils/json_type.hpp
src/utils/json_type.cpp
src/utils/is_complete_type.hpp
src/utils/formated_exception.hpp
src/utils/convert/json_serialize.hpp
src/utils/convert/json_parse.hpp
Expand All @@ -32,6 +37,7 @@ src/utils/convert/additional_properties.hpp
src/utils/constexpr_string.hpp
src/utils/constexpr_optional.hpp
src/utils/component_list_fwd.hpp
src/utils/component.hpp
src/utils/compilers_macros.hpp
src/utils/common_errors.hpp
src/openapi/types/uuid_type.hpp
Expand Down Expand Up @@ -88,18 +94,20 @@ src/openapi/from_tuple/property.hpp
src/openapi/from_tuple/optional.hpp
src/openapi/from_tuple/default.hpp
src/openapi/from_tuple/all.hpp
src/openapi/doc/serialize/uuid.hpp
src/openapi/doc/serialize/response.hpp
src/openapi/doc/serialize/request.hpp
src/openapi/doc/serialize/remove_requests.hpp
src/openapi/doc/serialize/reflective.hpp
src/openapi/doc/serialize/path.hpp
src/openapi/doc/serialize/header.hpp
src/openapi/doc/serialize/cookie.hpp
src/openapi/doc/serialize/body.hpp
src/openapi/doc/serialize/base.hpp
src/openapi/doc/serialize/array.hpp
src/openapi/doc/serialize/all.hpp
src/openapi/doc/uuid.hpp
src/openapi/doc/string.hpp
src/openapi/doc/response.hpp
src/openapi/doc/request.hpp
src/openapi/doc/reflective.hpp
src/openapi/doc/property.hpp
src/openapi/doc/path.hpp
src/openapi/doc/int.hpp
src/openapi/doc/header.hpp
src/openapi/doc/cookie.hpp
src/openapi/doc/body.hpp
src/openapi/doc/base.hpp
src/openapi/doc/array.hpp
src/openapi/doc/all.hpp
src/openapi/base/uuid_traits.hpp
src/openapi/base/uuid_property.hpp
src/openapi/base/string_traits.hpp
Expand Down Expand Up @@ -129,6 +137,11 @@ src/openapi/as_tuple/optional.hpp
src/openapi/as_tuple/default.hpp
src/openapi/as_tuple/all.hpp
src/openapi/all.hpp
src/models/user_credentials/type.hpp
src/models/user_credentials/postgres.hpp
src/models/user/type.hpp
src/models/user/postgres.hpp
src/models/error_v1/type.hpp
src/legacy/views/timetable/get/view.hpp
src/legacy/views/timetable/get/view.cpp
src/legacy/views/timetable/get/Responses.hpp
Expand Down Expand Up @@ -185,6 +198,7 @@ src/legacy/models/user_type/serialize.cpp
src/legacy/models/user_type/postgre.hpp
src/legacy/models/user_type/parse.hpp
src/legacy/models/user_type/parse.cpp
src/legacy/models/user_type/doc.hpp
src/legacy/models/user_credentials/type.hpp
src/legacy/models/user_credentials/postgre.hpp
src/legacy/models/user_credentials/fwd.hpp
Expand Down Expand Up @@ -323,3 +337,11 @@ src/legacy/components/controllers/postgres/admin/controller.cpp
src/http/legacy_handler_parsed.hpp
src/http/handler_parsed.hpp
src/http/ErrorV1.hpp
src/controllers/user/controller_fwd.hpp
src/controllers/user/controller.hpp
src/controllers/user/controller.cpp
src/controllers/token/controller_fwd.hpp
src/controllers/token/controller.hpp
src/controllers/token/controller.cpp
src/codegen/sql.hpp
src/codegen/sql.cpp
17 changes: 14 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ CMAKE_COMMON_FLAGS ?= -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMAKE_DEBUG_FLAGS ?= -DUSERVER_SANITIZE='addr ub'
CMAKE_RELEASE_FLAGS ?=
CMAKE_OS_FLAGS ?= -DUSERVER_FEATURE_CRYPTOPP_BLAKE2=0 -DUSERVER_FEATURE_REDIS_HI_MALLOC=1
FORMAT_INCLUDES_FLAGS ?= userver boost gtest openapi utils
FORMAT_INCLUDES_FLAGS ?= userver boost gtest openapi utils codegen
GENERATE_SQL_QUERIES_FLAGS ?= src/sql src/codegen sql sql
NPROCS ?= $(shell nproc)
CLANG_FORMAT ?= clang-format-11

Expand Down Expand Up @@ -161,8 +162,9 @@ check-format-cpp:
@find service -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
@find src -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
@find utests -name '*pp' -type f | xargs $(CLANG_FORMAT) -i --dry-run --Werror
.PHONY: gen
gen:

.PHONY: gen-sources
gen-sources:
@rm -rf .gen
@mkdir -p .gen

Expand All @@ -183,6 +185,15 @@ gen:
unite-api:
@python3 scripts/merge_yaml.py api/api.yaml united_api.yaml

.PHONY: gen-queries
gen-queries:
@python3 scripts/generate_sql_queries.py $(GENERATE_SQL_QUERIES_FLAGS)

.PHONY: gen
gen:
$(MAKE) gen-queries
$(MAKE) gen-sources

# # Internal hidden targets that are used only in docker environment
# --in-docker-start-debug --in-docker-start-release: --in-docker-start-%: install-%
# @sed -i 's/config_vars.yaml/config_vars.docker.yaml/g' /home/user/.local/etc/timetable_vsu_backend/static_config.yaml
Expand Down
18 changes: 15 additions & 3 deletions configs/static_config.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ components_manager:
handler-login:
path: /login
method: POST
load-enabled: false
task_processor: main-task-processor
handler-register:
path: /register
method: POST
method: POST
load-enabled: false
task_processor: main-task-processor
handler-timetable-get:
path: /timetable/get
Expand Down Expand Up @@ -101,8 +103,12 @@ components_manager:
path: /group-stage/list
method: POST
task_processor: main-task-processor
test-login-view:
path: /test/login
login-view:
path: /login
method: POST
task_processor: main-task-processor
register-view:
path: /register
method: POST
task_processor: main-task-processor
openapi-descriptor:
Expand Down Expand Up @@ -133,6 +139,12 @@ components_manager:
password: $root_password
id: $root_id
token_controller: {}
new-token-controller: {}
new-user-controller:
root:
login: $root_login
password: $root_password
id: $root_id
lesson_details_controller : {}
teacher_controller : {}
handler-ping:
Expand Down
22 changes: 17 additions & 5 deletions service/main.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <openapi/http/openapi_descriptor_fwd.hpp>
#include <userver/clients/dns/component.hpp>
#include <userver/clients/http/component.hpp>
#include <userver/components/component_list.hpp>
#include <userver/components/minimal_server_component_list.hpp>
#include <userver/formats/json/value.hpp>
#include <userver/logging/log.hpp>
Expand All @@ -11,6 +12,9 @@
#include <userver/utils/daemon_run.hpp>
#include <utility>

#include "controllers/token/controller_fwd.hpp"
#include "controllers/user/controller.hpp"
#include "controllers/user/controller_fwd.hpp"
#include "legacy/components/controllers/postgres/admin/fwd.hpp"
#include "legacy/components/controllers/postgres/faculty/fwd.hpp"
#include "legacy/components/controllers/postgres/group_stage/fwd.hpp"
Expand All @@ -31,7 +35,8 @@
#include "legacy/views/teacher/request/approve/new/view.hpp"
#include "legacy/views/teacher/request/list/view.hpp"
#include "legacy/views/timetable/get/view.hpp"
#include "views/test-openapi-view/view.hpp"
#include "views/login/view.hpp"
#include "views/register/view.hpp"

void AppendPgControllers(userver::components::ComponentList& component_list)
{
Expand All @@ -43,12 +48,13 @@ void AppendPgControllers(userver::components::ComponentList& component_list)
teacher::Append(component_list);
faculty::Append(component_list);
group_stage::Append(component_list);
controllers::token::Append(component_list);
controllers::user::Append(component_list);
}

void AppendViews(userver::components::ComponentList& component_list)
void AppendLegacyViews(userver::components::ComponentList& component_list)
{
using namespace legacy::views;
using namespace views;
login::Append(component_list);
register_::Append(component_list);
timetable::get::Append(component_list);
Expand All @@ -61,7 +67,13 @@ void AppendViews(userver::components::ComponentList& component_list)
teacher::requests::approve::new_::Append(component_list);
faculty::list::Append(component_list);
group::stage::list::Append(component_list);
test::login::Append(component_list);
}

void AppendViews(userver::components::ComponentList& component_list)
{
using namespace views;
login::Append(component_list);
Register::Append(component_list);
}

int main(int argc, char* argv[])
Expand All @@ -77,7 +89,7 @@ int main(int argc, char* argv[])
openapi::http::AppendOpenApiDescriptor(component_list);
service_template::AppendHello(component_list);
AppendPgControllers(component_list);
AppendLegacyViews(component_list);
AppendViews(component_list);

return userver::utils::DaemonMain(argc, argv, component_list);
}
2 changes: 1 addition & 1 deletion src/openapi/all.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <openapi/as_tuple/all.hpp>
#include <openapi/base/all.hpp>
#include <openapi/doc/serialize/all.hpp>
#include <openapi/doc/all.hpp>
#include <openapi/from_tuple/all.hpp>
#include <openapi/http/all.hpp>
#include <openapi/json/all.hpp>
Expand Down
2 changes: 1 addition & 1 deletion src/openapi/base/array_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct ArrayProperty : public PropertyBase<std::vector<T>, Traits>
};

template <typename T, typename Traits>
struct Property<std::vector<T>, Traits> : public ArrayProperty<T, Traits>
struct types::Property<std::vector<T>, Traits> : public ArrayProperty<T, Traits>
{
};

Expand Down
2 changes: 1 addition & 1 deletion src/openapi/base/object_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ requires checks::is_reflective_v<T> struct ObjectProperty
};

template <typename T, typename Traits>
requires checks::is_reflective_v<T> struct Property<T, Traits>
requires checks::is_reflective_v<T> struct types::Property<T, Traits>
: public ObjectProperty<T, Traits>
{
};
Expand Down
3 changes: 2 additions & 1 deletion src/openapi/base/optional_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ struct OptionalProperty : public PropertyBase<std::optional<T>, Traits>
};

template <typename T, typename Traits>
struct Property<std::optional<T>, Traits> : public OptionalProperty<T, Traits>
struct types::Property<std::optional<T>, Traits>
: public OptionalProperty<T, Traits>
{
};

Expand Down
13 changes: 11 additions & 2 deletions src/openapi/base/property_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,16 @@ struct PropertyBase
}

template <class Arg>
value_type& operator=(Arg&& arg)
auto& operator=(Arg&& arg)
{
value = std::forward<Arg>(arg);
return value;
}
auto& operator=(value_type rhs)
{
value = std::move(rhs);
return *this;
}
value_type& operator()()
{
return value;
Expand All @@ -60,9 +65,13 @@ concept IsProperty = requires
T>;
};

namespace types
{
template <typename T, typename Traits = EmptyTraits>
struct Property
struct Property : PropertyBase<T, Traits>
{
};

} // namespace types

} // namespace openapi
2 changes: 1 addition & 1 deletion src/openapi/base/string_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ struct StringProperty : public PropertyBase<std::string, Traits>
};

template <typename Traits>
struct Property<std::string, Traits> : public StringProperty<Traits>
struct types::Property<std::string, Traits> : public StringProperty<Traits>
{
};

Expand Down
2 changes: 1 addition & 1 deletion src/openapi/base/uuid_property.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ struct UuidProperty : PropertyBase<boost::uuids::uuid, Traits>
};

template <typename Traits>
struct Property<boost::uuids::uuid, Traits> : UuidProperty<Traits>
struct types::Property<boost::uuids::uuid, Traits> : UuidProperty<Traits>
{
};
} // namespace openapi
13 changes: 0 additions & 13 deletions src/openapi/doc/serialize/all.hpp

This file was deleted.

30 changes: 0 additions & 30 deletions src/openapi/doc/serialize/array.hpp

This file was deleted.

Loading

0 comments on commit afbc373

Please sign in to comment.