Improve the frontend 3

This commit is contained in:
Urtzi Alfaro
2025-10-30 21:08:07 +01:00
parent 36217a2729
commit 63f5c6d512
184 changed files with 21512 additions and 7442 deletions

View File

@@ -0,0 +1,44 @@
"""
FastAPI Dependencies for Procurement Service
"""
from fastapi import Header, HTTPException, status
from uuid import UUID
from typing import Optional
from sqlalchemy.ext.asyncio import AsyncSession
from .database import get_db
async def get_current_tenant_id(
x_tenant_id: Optional[str] = Header(None, alias="X-Tenant-ID")
) -> UUID:
"""
Extract and validate tenant ID from request header.
Args:
x_tenant_id: Tenant ID from X-Tenant-ID header
Returns:
UUID: Validated tenant ID
Raises:
HTTPException: If tenant ID is missing or invalid
"""
if not x_tenant_id:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail="X-Tenant-ID header is required"
)
try:
return UUID(x_tenant_id)
except (ValueError, AttributeError):
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST,
detail=f"Invalid tenant ID format: {x_tenant_id}"
)
# Re-export get_db for convenience
__all__ = ["get_db", "get_current_tenant_id"]