Refactor logistics and frontend code for better consistency.

Refactored several files to improve code clarity, error handling, and data integrity. Introduced type safety improvements, streamlined OpenAPI model integration, adjusted configuration settings, and enhanced QR code handling logic. Also updated scripts and tsconfig settings to temporarily bypass strict checks during development.
This commit is contained in:
GotthardG
2025-03-06 13:24:12 +01:00
parent 9c73e1df4c
commit 3d55c42312
9 changed files with 196 additions and 56 deletions

View File

@ -21,6 +21,16 @@ from app.routers.protected_router import protected_router
# Utility function to fetch metadata from pyproject.toml
def get_project_metadata():
script_dir = Path(__file__).resolve().parent
pyproject_path = script_dir / "pyproject.toml" # Check current directory first
if pyproject_path.exists():
with open(pyproject_path, "rb") as f:
pyproject = tomllib.load(f)
name = pyproject["project"]["name"]
version = pyproject["project"]["version"]
return name, version
# Search in parent directories
for parent in script_dir.parents:
pyproject_path = parent / "pyproject.toml"
if pyproject_path.exists():
@ -29,6 +39,7 @@ def get_project_metadata():
name = pyproject["project"]["name"]
version = pyproject["project"]["version"]
return name, version
raise FileNotFoundError(
f"pyproject.toml not found in any parent directory of {script_dir}"
)
@ -69,7 +80,7 @@ app = FastAPI(
# Determine environment and configuration file path
environment = os.getenv("ENVIRONMENT", "dev")
config_file = Path(__file__).resolve().parent.parent / f"config_{environment}.json"
config_file = Path(__file__).resolve().parent / f"config_{environment}.json"
if not config_file.exists():
raise FileNotFoundError(f"Config file '{config_file}' does not exist.")