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.
This commit is contained in:
GotthardG 2024-12-18 07:28:25 +01:00
parent 7f7f80b4f8
commit 0dff7c3c67
3 changed files with 3 additions and 1 deletions

View File

@ -4,6 +4,7 @@
"OPENAPI_URL": "https://127.0.0.1:8000/openapi.json",
"SCHEMA_PATH": "./src/openapi.json",
"OUTPUT_DIRECTORY": "./openapi",
"PORT": 8000,
"SSL_KEY_PATH": "../backend/ssl/key.pem",
"SSL_CERT_PATH": "../backend/ssl/cert.pem"
}

View File

@ -4,6 +4,7 @@
"OPENAPI_URL": "https://mx-aare-test.psi.ch:8000/openapi.json",
"SCHEMA_PATH": "./src/openapi.json",
"OUTPUT_DIRECTORY": "./openapi",
"PORT": 8081,
"SSL_KEY_PATH": "/home/jungfrau/heidi-v2/backend/ssl/mx-aare-test.psi.ch.key",
"SSL_CERT_PATH": "/home/jungfrau/heidi-v2/backend/ssl/mx-aare-test.psi.ch.pem"
}

View File

@ -22,7 +22,7 @@ const ShipmentView: React.FC<ShipmentViewProps> = () => {
OpenAPI.BASE =
mode === 'test'
? import.meta.env.VITE_OPENAPI_BASE_TEST
: mode === 'production'
: mode === 'prod'
? import.meta.env.VITE_OPENAPI_BASE_PROD
: import.meta.env.VITE_OPENAPI_BASE_DEV;