From 29643a3075a245ef2825950bc1f80ff0c8b1e970 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 00:06:19 -0700 Subject: [PATCH 01/18] remove debugging ls command --- .dockerignore | 10 +++++++++- .github/workflows/cmake-multi-platform.yml | 1 - 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.dockerignore b/.dockerignore index 6d21dc52..93d47c42 100644 --- a/.dockerignore +++ b/.dockerignore @@ -4,6 +4,14 @@ out/ .git/ .gitignore .gitattributes -Dockerfile +Dockerfile* docker-compose.yml *.code-workspace +vcpkg_installed/ +ssl/ +out/ +cmake-build-*/ +build/ +.idea/ +Testing/ +*.code-workspace diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 86b8912c..9ddadd37 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -198,7 +198,6 @@ jobs: - name: Create Release Variables run: | - ls -al ${{ github.workspace }}/artifacts export RELEASE_VERSION="${{vars.RELEASE_VERSION_PREFIX}}.${{github.run_number}}" echo "RELEASE_VERSION=$RELEASE_VERSION" >> $GITHUB_ENV export RELEASE_TAG="v${RELEASE_VERSION}" From 3cf430698b86a0acad942ae3fdf5ce034ee6e8e1 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:30:46 -0700 Subject: [PATCH 02/18] add GetFileModel() to Design --- OdbDesignLib/Design.cpp | 5 +++++ OdbDesignLib/Design.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/OdbDesignLib/Design.cpp b/OdbDesignLib/Design.cpp index 2393e7e6..0f18d16b 100644 --- a/OdbDesignLib/Design.cpp +++ b/OdbDesignLib/Design.cpp @@ -36,6 +36,11 @@ namespace Odb::Lib::ProductModel return true; } + std::shared_ptr Design::GetFileModel() const + { + return m_pFileModel; + } + bool Design::BuildComponents() { if (m_pFileModel == nullptr) return false; diff --git a/OdbDesignLib/Design.h b/OdbDesignLib/Design.h index 942f2d01..f9b64d85 100644 --- a/OdbDesignLib/Design.h +++ b/OdbDesignLib/Design.h @@ -22,6 +22,8 @@ namespace Odb::Lib::ProductModel bool Build(std::string path); bool Build(std::shared_ptr pFileModel); + std::shared_ptr GetFileModel() const; + typedef std::vector> Vector; typedef std::map> StringMap; From c82964e2521c1fddc1f6af1f86fc0e16efe55c7a Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:31:18 -0700 Subject: [PATCH 03/18] rename design_cache() to designs() --- OdbDesignLib/IOdbApp.h | 2 +- OdbDesignLib/OdbAppBase.cpp | 2 +- OdbDesignLib/OdbAppBase.h | 2 +- OdbDesignServer/Controllers/StepsEdaDataController.cpp | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/OdbDesignLib/IOdbApp.h b/OdbDesignLib/IOdbApp.h index e3941fa5..2ef0ce4b 100644 --- a/OdbDesignLib/IOdbApp.h +++ b/OdbDesignLib/IOdbApp.h @@ -13,7 +13,7 @@ namespace Odb::Lib virtual ~IOdbApp() {} virtual const OdbDesignArgs& args() const = 0; - virtual DesignCache& design_cache() = 0; + virtual DesignCache& designs() = 0; virtual Utils::ExitCode Run() = 0; diff --git a/OdbDesignLib/OdbAppBase.cpp b/OdbDesignLib/OdbAppBase.cpp index 2f3bd86e..d5fa05e0 100644 --- a/OdbDesignLib/OdbAppBase.cpp +++ b/OdbDesignLib/OdbAppBase.cpp @@ -23,7 +23,7 @@ namespace Odb::Lib return m_commandLineArgs; } - DesignCache& OdbAppBase::design_cache() + DesignCache& OdbAppBase::designs() { return m_designCache; } diff --git a/OdbDesignLib/OdbAppBase.h b/OdbDesignLib/OdbAppBase.h index e6fab74e..792a1b86 100644 --- a/OdbDesignLib/OdbAppBase.h +++ b/OdbDesignLib/OdbAppBase.h @@ -14,7 +14,7 @@ namespace Odb::Lib virtual ~OdbAppBase(); const OdbDesignArgs& args() const override; - DesignCache& design_cache() override; + DesignCache& designs() override; virtual Utils::ExitCode Run() override; diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index 2f1cddfb..4a5483a2 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -58,7 +58,7 @@ namespace Odb::App::Server return crow::response(crow::status::BAD_REQUEST, "step name not specified"); } - auto pFileArchive = m_serverApp.design_cache().GetFileArchive(designName); + auto pFileArchive = m_serverApp.designs().GetFileArchive(designName); if (pFileArchive == nullptr) { std::stringstream ss; From 4e7b9f840b03125b1a0a654f7b2f034441f51b79 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:32:57 -0700 Subject: [PATCH 04/18] use const char* instead of std::string for string constant --- Utils/JsonCrowReturnable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Utils/JsonCrowReturnable.h b/Utils/JsonCrowReturnable.h index 4434e4ce..aeb227d5 100644 --- a/Utils/JsonCrowReturnable.h +++ b/Utils/JsonCrowReturnable.h @@ -13,7 +13,7 @@ namespace Utils : Utils::CrowReturnable(odbObject, CONTENT_TYPE) {} - inline static const std::string CONTENT_TYPE = "application/json"; + inline constexpr static const char* CONTENT_TYPE = "application/json"; protected: std::string to_string() const override; From 6a3e96f061932abe7c086dbb212b67921355e977 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:34:20 -0700 Subject: [PATCH 05/18] use references with auto to avoid unncessary copying --- OdbDesignServer/Controllers/StepsEdaDataController.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index 4a5483a2..72a0b37b 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -66,7 +66,7 @@ namespace Odb::App::Server return crow::response(crow::status::BAD_REQUEST, ss.str()); } - auto stepsByName = pFileArchive->GetStepsByName(); + auto& stepsByName = pFileArchive->GetStepsByName(); auto findIt = stepsByName.find(stepName); if (findIt == stepsByName.end()) { @@ -75,8 +75,8 @@ namespace Odb::App::Server return crow::response(crow::status::BAD_REQUEST, ss.str()); } - auto step = findIt->second; - auto edaDataFile = step->GetEdaDataFile(); + auto& step = findIt->second; + auto& edaDataFile = step->GetEdaDataFile(); return crow::response(JsonCrowReturnable(edaDataFile)); } } From a7a3856aa0c67d73ade612d4689e16705fc83ca7 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:34:43 -0700 Subject: [PATCH 06/18] add GetFilename() to FileArchive class --- OdbDesignLib/FileArchive.cpp | 18 ++++++++++++++++-- OdbDesignLib/FileArchive.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/OdbDesignLib/FileArchive.cpp b/OdbDesignLib/FileArchive.cpp index 659d8366..6fe1500f 100644 --- a/OdbDesignLib/FileArchive.cpp +++ b/OdbDesignLib/FileArchive.cpp @@ -1,5 +1,4 @@ #include "FileArchive.h" -#include "FileArchive.h" #include #include "ArchiveExtractor.h" #include "MiscInfoFile.h" @@ -7,6 +6,7 @@ #include "Logger.h" using namespace Utils; +using namespace std::filesystem; namespace Odb::Lib::FileModel::Design { @@ -30,7 +30,15 @@ namespace Odb::Lib::FileModel::Design return m_productName; } - const StepDirectory::StringMap& FileArchive::GetStepsByName() const { return m_stepsByName; } + std::string FileArchive::GetFilename() const + { + return path(m_path).filename().string(); + } + + const StepDirectory::StringMap& FileArchive::GetStepsByName() const + { + return m_stepsByName; + } bool FileArchive::ParseFileModel() { @@ -99,6 +107,7 @@ namespace Odb::Lib::FileModel::Design if (!std::filesystem::exists(path)) return false; else if (!std::filesystem::is_directory(path)) return false; + // TODO: this should use path.stem() instead of path.filename() m_productName = path.filename().string(); auto stepsPath = path / "steps"; @@ -167,6 +176,11 @@ namespace Odb::Lib::FileModel::Design return m_matrixFile; } + const StandardFontsFile& FileArchive::GetStandardFontsFile() const + { + return m_standardFontsFile; + } + //const EdaDataFile& FileModel::GetStepEdaDataFile(std::string stepName) const //{ // auto findIt = m_stepsByName.find(stepName); diff --git a/OdbDesignLib/FileArchive.h b/OdbDesignLib/FileArchive.h index f8ad9f92..232d44bd 100644 --- a/OdbDesignLib/FileArchive.h +++ b/OdbDesignLib/FileArchive.h @@ -21,6 +21,7 @@ namespace Odb::Lib::FileModel::Design std::string GetPath() const; std::string GetProductName() const; + std::string GetFilename() const; const StepDirectory::StringMap& GetStepsByName() const; const MiscInfoFile& GetMiscInfoFile() const; From 74a56807444435a0fb671015c230661ebb73bd29 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:36:02 -0700 Subject: [PATCH 07/18] add methods for getting loaded and unloaded designs/file archives --- OdbDesignLib/DesignCache.cpp | 42 ++++++++++++++++++++++++++++++++++++ OdbDesignLib/DesignCache.h | 6 ++++++ 2 files changed, 48 insertions(+) diff --git a/OdbDesignLib/DesignCache.cpp b/OdbDesignLib/DesignCache.cpp index f36f835c..599da340 100644 --- a/OdbDesignLib/DesignCache.cpp +++ b/OdbDesignLib/DesignCache.cpp @@ -5,6 +5,7 @@ #include using namespace Utils; +using namespace std::filesystem; namespace Odb::Lib { @@ -57,6 +58,47 @@ namespace Odb::Lib return m_fileArchivesByName[designName]; } + std::vector DesignCache::getLoadedDesignNames(const std::string& filter) const + { + std::vector loadedDesigns; + for (const auto& kv : m_designsByName) + { + loadedDesigns.push_back(kv.second->GetFileModel()->GetFilename()); + } + return loadedDesigns; + } + + std::vector DesignCache::getLoadedFileArchiveNames(const std::string& filter) const + { + std::vector loadedFileArchives; + for (const auto& kv : m_fileArchivesByName) + { + loadedFileArchives.push_back(kv.second->GetFilename()); + } + return loadedFileArchives; + } + + std::vector DesignCache::getUnloadedNames(const std::string& filter) const + { + std::vector unloadedNames; + + path dir(m_directory); + for (const auto& entry : directory_iterator(dir)) + { + if (entry.is_regular_file()) + { + unloadedNames.push_back(entry.path().filename().string()); + } + } + + return unloadedNames; + } + + bool DesignCache::isQueryValid(const std::string& query) const + { + return false; + } + void DesignCache::Clear() { m_fileArchivesByName.clear(); diff --git a/OdbDesignLib/DesignCache.h b/OdbDesignLib/DesignCache.h index 02f27671..f0ce9e0c 100644 --- a/OdbDesignLib/DesignCache.h +++ b/OdbDesignLib/DesignCache.h @@ -17,6 +17,12 @@ namespace Odb::Lib std::shared_ptr GetDesign(const std::string& designName); std::shared_ptr GetFileArchive(const std::string& designName); + std::vector getLoadedDesignNames(const std::string& filter = "") const; + std::vector getLoadedFileArchiveNames(const std::string& filter = "") const; + std::vector getUnloadedNames(const std::string& filter = "") const; + + bool isQueryValid(const std::string& query) const; + void Clear(); private: From b666eeac1dd548afb299db5e0437c797883e53bb Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:37:53 -0700 Subject: [PATCH 08/18] refactor so LoadDesign() uses a loaded FileArchive if it already exists to build the design (as well as places FileArchives loaded via LoadDesign into the cache) --- OdbDesignLib/DesignCache.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/OdbDesignLib/DesignCache.cpp b/OdbDesignLib/DesignCache.cpp index 599da340..eacd0bbe 100644 --- a/OdbDesignLib/DesignCache.cpp +++ b/OdbDesignLib/DesignCache.cpp @@ -106,7 +106,8 @@ namespace Odb::Lib } std::shared_ptr DesignCache::LoadDesign(const std::string& designName) - { + { + // no FileArchive with the same name is loaded, so load the Design from file std::filesystem::path dir(m_directory); for (const auto& entry : std::filesystem::directory_iterator(dir)) @@ -115,11 +116,15 @@ namespace Odb::Lib { if (entry.path().stem() == designName) { - auto pDesign = std::make_shared(); - if (pDesign->Build(entry.path().string())) + auto pFileModel = GetFileArchive(designName); + if (pFileModel != nullptr) { - m_designsByName.emplace(designName, pDesign); - return pDesign; + auto pDesign = std::make_shared(); + if (pDesign->Build(pFileModel)) + { + m_designsByName.emplace(designName, pDesign); + return pDesign; + } } } } From 537783512367e47cab5648d0775ae0fa4e545727 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:38:35 -0700 Subject: [PATCH 09/18] and empty method for sanitizing filename provided by api client --- OdbDesignServer/Controllers/FileUploadController.cpp | 5 +++++ OdbDesignServer/Controllers/FileUploadController.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/OdbDesignServer/Controllers/FileUploadController.cpp b/OdbDesignServer/Controllers/FileUploadController.cpp index 45330f0a..56d5e418 100644 --- a/OdbDesignServer/Controllers/FileUploadController.cpp +++ b/OdbDesignServer/Controllers/FileUploadController.cpp @@ -99,4 +99,9 @@ namespace Odb::App::Server } return crow::response(200); } + + std::string FileUploadController::sanitizeFilename(const std::string& filename) const + { + return filename; + } } \ No newline at end of file diff --git a/OdbDesignServer/Controllers/FileUploadController.h b/OdbDesignServer/Controllers/FileUploadController.h index 5a0a1c2a..81790016 100644 --- a/OdbDesignServer/Controllers/FileUploadController.h +++ b/OdbDesignServer/Controllers/FileUploadController.h @@ -16,5 +16,7 @@ namespace Odb::App::Server crow::response handleOctetStreamUpload(const std::string& filename, const crow::request& req); crow::response handleMultipartFormUpload(const std::string& filename, const crow::request& req); + std::string sanitizeFilename(const std::string& filename) const; + }; } From f154c0676eb47ab2eab40b284888e54878348589 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 16:39:03 -0700 Subject: [PATCH 10/18] add endpoints for listing the available designs --- .../Controllers/FileUploadController.cpp | 68 ++++++++++++++++--- 1 file changed, 58 insertions(+), 10 deletions(-) diff --git a/OdbDesignServer/Controllers/FileUploadController.cpp b/OdbDesignServer/Controllers/FileUploadController.cpp index 56d5e418..aae91eec 100644 --- a/OdbDesignServer/Controllers/FileUploadController.cpp +++ b/OdbDesignServer/Controllers/FileUploadController.cpp @@ -1,5 +1,7 @@ #include "FileUploadController.h" +using namespace std::filesystem; + namespace Odb::App::Server { FileUploadController::FileUploadController(Odb::Lib::IOdbServerApp& serverApp) @@ -8,7 +10,7 @@ namespace Odb::App::Server } void FileUploadController::register_routes() { - CROW_ROUTE(m_serverApp.crow_app(), "/files/upload/").methods(crow::HTTPMethod::POST) + CROW_ROUTE(m_serverApp.crow_app(), "/designs/upload/").methods(crow::HTTPMethod::POST) ([&](const crow::request& req, std::string filename) { const auto& contentType = req.get_header_value("Content-Type"); @@ -25,22 +27,68 @@ namespace Odb::App::Server return crow::response(crow::status::BAD_REQUEST, "incorrect content type"); } }); - } + CROW_ROUTE(m_serverApp.crow_app(), "/designs/list").methods(crow::HTTPMethod::GET) + ([&](const crow::request& req) + { + auto designNames = m_serverApp.designs().getUnloadedNames(); + if (designNames.empty()) + { + return crow::response(crow::status::NOT_FOUND, "no designs found"); + } + + crow::json::wvalue jsonResponse; + jsonResponse["names"] = designNames; + +#if defined(_DEBUG) + auto j = jsonResponse.dump(); +#endif + + return crow::response(jsonResponse); + }); + + CROW_ROUTE(m_serverApp.crow_app(), "/designs/list/").methods(crow::HTTPMethod::GET) + ([&](const crow::request& req, std::string query) + { + if (! m_serverApp.designs().isQueryValid(query)) + { + return crow::response(crow::status::BAD_REQUEST, "invalid query"); + } + + auto designNames = m_serverApp.designs().getUnloadedNames(query); + if (designNames.empty()) + { + return crow::response(crow::status::NOT_FOUND, "no matching design names found"); + } + + crow::json::wvalue jsonResponse; + jsonResponse["names"] = designNames; + +#if defined(_DEBUG) + auto j = jsonResponse.dump(); +#endif + + return crow::response(jsonResponse); + }); + } + crow::response FileUploadController::handleOctetStreamUpload(const std::string& filename, const crow::request& req) { - // TODO: generate random temp filename - const auto tempFilename = "temp.upload"; - std::ofstream outfile(tempFilename, std::ofstream::binary); + const auto tempPath = temp_directory_path() / std::tmpnam(nullptr); + std::ofstream outfile(tempPath, std::ofstream::binary); outfile << req.body; outfile.close(); - // TODO: sanitize filename - std::filesystem::path finalPath(m_serverApp.args().designsDir()); - finalPath /= filename; - std::filesystem::rename(tempFilename, finalPath); + // TODO: sanitize provided filename + auto safeName = sanitizeFilename(filename); + + path finalPath(m_serverApp.args().designsDir()); + finalPath /= safeName; + rename(tempPath, finalPath); + + std::string responseBody = "{ \"filename\": \"" + safeName + "\" }"; - return crow::response(crow::status::OK); + return crow::response(crow::status::OK, responseBody); } crow::response FileUploadController::handleMultipartFormUpload(const std::string& filename, const crow::request& req) From f2c7620ee4ff3519fe334e347f2b2eae4a096f26 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 17:23:29 -0700 Subject: [PATCH 11/18] add a description label to Docker image --- Dockerfile_OdbDesignServer | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Dockerfile_OdbDesignServer b/Dockerfile_OdbDesignServer index b37a1c6f..41a66963 100644 --- a/Dockerfile_OdbDesignServer +++ b/Dockerfile_OdbDesignServer @@ -67,6 +67,9 @@ RUN cmake --build --preset linux-release # much smaller runtime image FROM debian:bookworm-20231009-slim AS run +LABEL org.opencontainers.image.description = "The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." + +EXPOSE 8888 RUN mkdir --parents /OdbDesign/bin WORKDIR /OdbDesign/bin From 0f93595f7af2d57cbe8a0c86f4618fbb81deaef2 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 17:23:59 -0700 Subject: [PATCH 12/18] add a file containing markup to be used for the body notes when creating a release --- release/release-body.md | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 release/release-body.md diff --git a/release/release-body.md b/release/release-body.md new file mode 100644 index 00000000..b5f46d24 --- /dev/null +++ b/release/release-body.md @@ -0,0 +1,7 @@ +## Docker + +The signed Docker image for this release can be found here: + +* [nam20485/odbdesign:release-latest](https://github.com/nam20485/OdbDesign/pkgs/container/odbdesign/139993649?tag=release-latest) + +_If a specific tag that changes with each release is required, you can find the matching tag of the form `release-nnn`, where `nnn` is an monotonically-increasing integer, on the same page._ From de0404a491291b06cf2224068bc6268c32d6d3c9 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 17:43:20 -0700 Subject: [PATCH 13/18] add body to created release with contents of markdown file --- .github/workflows/cmake-multi-platform.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml index 9ddadd37..af2c6033 100644 --- a/.github/workflows/cmake-multi-platform.yml +++ b/.github/workflows/cmake-multi-platform.yml @@ -218,12 +218,13 @@ jobs: github-token: "${{ secrets.GITHUB_TOKEN }}" script: | try { - const createResponse = await github.rest.repos.createRelease({ + const createResponse = await github.rest.repos.createRelease({ generate_release_notes: true, name: process.env.RELEASE_NAME, owner: context.repo.owner, repo: context.repo.repo, tag_name: process.env.RELEASE_TAG, + body: require('fs').readFileSync('${{ github.workspace }}/release/release-body.md', 'utf8'), target_commitish: '${{ github.ref_name }}' }); @@ -234,7 +235,7 @@ jobs: ]; for (const filename of filenames) { - const artifactsPath = 'artifacts'; + const artifactsPath = '${{ github.workspace }}/artifacts'; const filePath = artifactsPath +'/' + filename; const uploadResponse = await github.rest.repos.uploadReleaseAsset({ owner: context.repo.owner, From a774e1375ec781800eb598384f14a1cb9261f295 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Mon, 23 Oct 2023 18:21:03 -0700 Subject: [PATCH 14/18] return HTTP 404 NOT_FOUND if design name or step name can't be found --- OdbDesignServer/Controllers/StepsEdaDataController.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index 72a0b37b..6c834877 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -63,7 +63,7 @@ namespace Odb::App::Server { std::stringstream ss; ss << "design: \"" << designName << "\" not found"; - return crow::response(crow::status::BAD_REQUEST, ss.str()); + return crow::response(crow::status::NOT_FOUND, ss.str()); } auto& stepsByName = pFileArchive->GetStepsByName(); @@ -72,7 +72,7 @@ namespace Odb::App::Server { std::stringstream ss; ss << "step: \"" << stepName << "\" not found"; - return crow::response(crow::status::BAD_REQUEST, ss.str()); + return crow::response(crow::status::NOT_FOUND, ss.str()); } auto& step = findIt->second; From c22d685841b1be5217fc4543287972fa08ffa845 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Tue, 24 Oct 2023 09:09:34 -0700 Subject: [PATCH 15/18] delete cpp.hint --- cpp.hint | 6 ------ 1 file changed, 6 deletions(-) delete mode 100644 cpp.hint diff --git a/cpp.hint b/cpp.hint deleted file mode 100644 index fc668fd7..00000000 --- a/cpp.hint +++ /dev/null @@ -1,6 +0,0 @@ -// Hint files help the Visual Studio IDE interpret Visual C++ identifiers -// such as names of functions and macros. -// For more information see https://go.microsoft.com/fwlink/?linkid=865984 -#define DECLSPEC __declspec(dllexport) -#define DECLSPEC __declspec(dllimport) -#define DECLSPEC From ebe3f9c7269873d3f85c9713edb9cd271ea796af Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Tue, 24 Oct 2023 09:17:30 -0700 Subject: [PATCH 16/18] mention design name on step not found error response --- OdbDesignServer/Controllers/StepsEdaDataController.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index 6c834877..fb63f905 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -71,7 +71,7 @@ namespace Odb::App::Server if (findIt == stepsByName.end()) { std::stringstream ss; - ss << "step: \"" << stepName << "\" not found"; + ss << "(design: \"" << designName << "\")" << " step: \"" << stepName << "\" not found"; return crow::response(crow::status::NOT_FOUND, ss.str()); } From 620e6a5ee48fcc28c8641d4aeb1ef0f52eb52de9 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Tue, 24 Oct 2023 09:33:16 -0700 Subject: [PATCH 17/18] add some LABELs to docker image --- Dockerfile_OdbDesignServer | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile_OdbDesignServer b/Dockerfile_OdbDesignServer index 41a66963..90c88080 100644 --- a/Dockerfile_OdbDesignServer +++ b/Dockerfile_OdbDesignServer @@ -67,8 +67,10 @@ RUN cmake --build --preset linux-release # much smaller runtime image FROM debian:bookworm-20231009-slim AS run +LABEL org.opencontainers.image.source=https://github.com/nam20485/OdbDesign +LABEL org.opencontainers.image.authors="https://github.com/nam20485" LABEL org.opencontainers.image.description = "The OdbDesign Docker image runs the OdbDesignServer REST API server executable, listening on port 8888." - +LABEL org.opencontainers.image.licenses=MIT EXPOSE 8888 RUN mkdir --parents /OdbDesign/bin From a40e9090ac3b12f9aa314f8822c85c0eadd5c944 Mon Sep 17 00:00:00 2001 From: Nathan Miller Date: Tue, 24 Oct 2023 09:33:35 -0700 Subject: [PATCH 18/18] remove old comments --- .../Controllers/StepsEdaDataController.cpp | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/OdbDesignServer/Controllers/StepsEdaDataController.cpp b/OdbDesignServer/Controllers/StepsEdaDataController.cpp index fb63f905..1ff70845 100644 --- a/OdbDesignServer/Controllers/StepsEdaDataController.cpp +++ b/OdbDesignServer/Controllers/StepsEdaDataController.cpp @@ -19,20 +19,16 @@ namespace Odb::App::Server { // // /steps/edadata?design=sample_design&step=stepName - // - - //app.route(url) - //app.route_dynamic(url) - + // // TODO: figure out why capture here is weird (i.e. how to capture pServerApp so it can be used in the member fxn handler) CROW_ROUTE(m_serverApp.crow_app(), "/designs//steps//eda_data") ([&](const crow::request& req, std::string designName, std::string stepName) { - ///steps//eda_data - //, std::string designName, std::string stepName return this->steps_edadata_route_handler(designName, stepName, req); }); + //app.route_dynamic(url) + //register_route_handler("/steps/edadata/package_records", std::bind(&StepsEdaDataController::steps_edadata_route_handler, this, std::placeholders::_1)); /*[&](const crow::request& req) { @@ -44,15 +40,11 @@ namespace Odb::App::Server const std::string& stepName, const crow::request& req) { - //auto designName = req.url_params.get("design"); - //if (designName == nullptr || strlen(designName) == 0) if (designName.empty()) { return crow::response(crow::status::BAD_REQUEST, "design name not specified"); } - //auto stepName = req.url_params.get("step"); - //if (stepName == nullptr || strlen(stepName) == 0) if (stepName.empty()) { return crow::response(crow::status::BAD_REQUEST, "step name not specified");