--- /dev/null
+BasedOnStyle: WebKit
+DerivePointerAlignment: false
+PointerAlignment: Left
+SpaceBeforeParens: ControlStatements
+AlignConsecutiveAssignments: true
+AlignConsecutiveMacros: true
+AlignEscapedNewlines: true
+AlignTrailingComments: true
+IndentWidth: 4
+BreakConstructorInitializers: BeforeComma
+BinPackArguments: false
+AllowAllArgumentsOnNextLine: false
+AllowAllParametersOfDeclarationOnNextLine: false
+BinPackParameters: false
+AlignAfterOpenBracket: AlwaysBreak
+AlwaysBreakTemplateDeclarations: Yes
+ColumnLimit: 80
+AllowShortEnumsOnASingleLine: true
+AllowShortCaseLabelsOnASingleLine: true
+AllowShortFunctionsOnASingleLine: Empty
+AllowShortIfStatementsOnASingleLine: WithoutElse
+AccessModifierOffset: -2
+BreakBeforeBraces: Custom
+BraceWrapping:
+ AfterControlStatement: Always
+ AfterFunction: true
+ AfterNamespace: true
+ AfterStruct: true
+ AfterClass: true
+ BeforeElse: true
+ BeforeCatch: true
+ BeforeLambdaBody: false
+ SplitEmptyRecord: true
+ SplitEmptyNamespace: true
+
--- /dev/null
+.ccls-cache
+compile_commands.json
+build
--- /dev/null
+[submodule "vendor/Crow"]
+ path = vendor/Crow
+ url = https://github.com/aloussase/Crow
--- /dev/null
+cmake_minimum_required(VERSION 3.18)
+
+project(open-the-box)
+
+set(CMAKE_CXX_STANDARD 20)
+
+set(DCROW_BUILD_EXAMPLES OFF)
+set(CROW_BUILD_TESTS OFF)
+set(CROW_ENABLE_SSL OFF)
+add_subdirectory(vendor/Crow)
+
+add_executable(open-the-box main.cpp
+ question.cpp
+ question_repository.cpp
+ question_dto.cpp)
+target_link_libraries(open-the-box PUBLIC Crow::Crow)
--- /dev/null
+# open-the-box
+
+## Setup
+
+### MacOS
+
+To make homebrew installed libraries work with CMake, you may need to add
+`/opt/homebrew` to its search path:
+
+```bash
+export CMAKE_PREFIX_PATH="/opt/homebrew:$CMAKE_PREFIX_PATH"
+```
+
+More information on:
+https://stackoverflow.com/questions/79481069/cmake-cannot-found-libraries-installed-by-brew.
--- /dev/null
+#include <crow.h>
+
+#include "question.hpp"
+#include "question_dto.hpp"
+#include "question_repository.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());
+ }
+
+ return crow::json::wvalue { dtos };
+ });
+
+ app.port(18080).multithreaded().run();
+
+ return 0;
+}
--- /dev/null
+#include "question.hpp"
+
+Question::Question(std::string s) noexcept
+ : m_question { std::move(s) }
+{
+}
+
+Question::Question(const char* s) noexcept
+ : m_question { s }
+{
+}
+
+std::string Question::question() noexcept
+{
+ return m_question;
+}
--- /dev/null
+#pragma once
+
+#include <string>
+
+class Question
+{
+ public:
+ std::string question() noexcept;
+ [[nodiscard]] Question(std::string) noexcept;
+ [[nodiscard]] Question(const char*) noexcept;
+
+ private:
+ std::string m_question;
+};
--- /dev/null
+#include "question_dto.hpp"
+
+QuestionDto::QuestionDto(Question question) noexcept
+ : m_question(std::move(question.question()))
+{
+}
+
+crow::json::wvalue QuestionDto::json() const noexcept
+{
+ crow::json::wvalue json;
+ json["question"] = m_question;
+ return json;
+}
--- /dev/null
+#pragma once
+
+#include "question.hpp"
+#include <crow.h>
+
+class QuestionDto
+{
+ public:
+ [[nodiscard]] QuestionDto(Question) noexcept;
+ crow::json::wvalue json() const noexcept;
+
+ private:
+ std::string m_question;
+};
--- /dev/null
+#include "question_repository.hpp"
+
+static std::vector<Question> questions
+ = { "What does your morning routine look like?",
+ "What do you like the most about your job?" };
+
+std::vector<Question> InMemoryQuestionRepository::list_questions() noexcept
+{
+ return questions;
+}
--- /dev/null
+#pragma once
+
+#include "question.hpp"
+#include <vector>
+class QuestionRepository
+{
+ public:
+ [[nodiscard]] virtual std::vector<Question> list_questions() noexcept = 0;
+};
+
+class InMemoryQuestionRepository : public QuestionRepository
+{
+ public:
+ std::vector<Question> list_questions() noexcept;
+};
--- /dev/null
+Subproject commit bbaf5c1ea0b8f05d53059937a5af6194b5e6b9ff