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-17 16:47:04 +01:00
parent 9b6ad107bb
commit 2581d7cedc

View File

@ -16,9 +16,13 @@ const ShipmentView: React.FC<ShipmentViewProps> = () => {
useEffect(() => {
const isTestEnv = import.meta.env.MODE === 'test';
const isProdEnv = import.meta.env.MODE === 'prod';
OpenAPI.BASE = isTestEnv
? import.meta.env.VITE_OPENAPI_BASE_TEST
: isProdEnv
? import.meta.env.VITE_OPENAPI_BASE_PROD
: import.meta.env.VITE_OPENAPI_BASE_DEV;
fetchAndSetShipments();
}, []);