BinPackParameters: false
AlignAfterOpenBracket: AlwaysBreak
AlwaysBreakTemplateDeclarations: Yes
-ColumnLimit: 80
+ColumnLimit: 100
AllowShortEnumsOnASingleLine: true
AllowShortCaseLabelsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
project(open-the-box)
-set(CMAKE_CXX_STANDARD 20)
+set(CMAKE_CXX_STANDARD 23)
set(DCROW_BUILD_EXAMPLES OFF)
set(CROW_BUILD_TESTS OFF)
#include <crow.h>
+#include <ranges>
#include "question.hpp"
#include "question_dto.hpp"
auto main() -> int
{
crow::SimpleApp app;
-
InMemoryQuestionRepository questions;
CROW_ROUTE(app, "/questions")([&]() {
- auto qs = questions.list_questions();
- crow::json::wvalue::list dtos;
- for (auto q : qs)
- {
- dtos.push_back(QuestionDto(q).json());
- }
-
+ auto dtos = questions.list_questions()
+ | std::views::transform([](auto q) { return QuestionDto(q).json(); })
+ | std::ranges::to<std::vector>();
return crow::json::wvalue { dtos };
});
+ // TODO: Fetch port from env variable.
app.port(18080).multithreaded().run();
return 0;
#include "question_repository.hpp"
+// TODO: Implement an external provider for questions.
static std::vector<Question> questions
= { "What does your morning routine look like?",
"What do you like the most about your job?" };