From 7727467e292dc883a44a80eed0d47ae50e535183 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Wed, 18 Dec 2024 07:57:51 +0100 Subject: [PATCH] Refactor OpenAPI fetcher for improved clarity and robustness Reorganized and enhanced the OpenAPI fetch logic for better maintainability and error handling. Key updates include improved environment variable validation, more detailed error messages, streamlined configuration loading, and additional safety checks for file paths and directories. Added proper logging and ensured the process flow is easy to trace. --- backend/main.py | 15 ++++++++------- logistics/package.json | 3 ++- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/backend/main.py b/backend/main.py index b7b2126..8204356 100644 --- a/backend/main.py +++ b/backend/main.py @@ -193,17 +193,18 @@ if __name__ == "__main__": ) # Run in CI mode - if is_ci: # CI mode - print("CI mode detected: Starting server in a subprocess...") - # Ensure SSL directory exists - ssl_dir = Path("ssl") + # Generate or use SSL Key and Certificate + if environment in ["test", "dev", "ci"]: + ssl_dir = Path( + cert_path + ).parent # Ensure we work with the parent directory of the cert path ssl_dir.mkdir( parents=True, exist_ok=True - ) # Create ssl directory if it doesn't exist + ) # Create the directory structure if it doesn't exist - # Ensure SSL certificate and key exist + # Generate self-signed certs if missing if not Path(cert_path).exists() or not Path(key_path).exists(): - print("Generating SSL certificates for CI mode...") + print(f"[INFO] Generating self-signed SSL certificates at {ssl_dir}") ssl_heidi.generate_self_signed_cert(cert_path, key_path) server_process = Process(target=run_server) diff --git a/logistics/package.json b/logistics/package.json index 7cfe21d..a48756f 100644 --- a/logistics/package.json +++ b/logistics/package.json @@ -9,7 +9,8 @@ "lint": "eslint .", "preview": "vite preview", "start-dev": "vite --mode dev", - "start-test": "vite --mode test" + "start-test": "vite --mode test", + "start-prod": "vite --mode prod" }, "dependencies": { "@emotion/react": "^11.13.3",