REFACTOR ALL APIs fix 1

This commit is contained in:
Urtzi Alfaro
2025-10-07 07:15:07 +02:00
parent 38fb98bc27
commit 7c72f83c51
47 changed files with 1821 additions and 270 deletions

View File

@@ -36,7 +36,7 @@ PUBLIC_ROUTES = [
"/api/v1/nominatim/search",
"/api/v1/plans",
"/api/v1/demo/accounts",
"/api/v1/demo/session/create"
"/api/v1/demo/sessions"
]
class AuthMiddleware(BaseHTTPMiddleware):

View File

@@ -77,10 +77,9 @@ class DemoMiddleware(BaseHTTPMiddleware):
# Skip demo middleware for demo service endpoints
demo_service_paths = [
"/api/v1/demo/accounts",
"/api/v1/demo/session/create",
"/api/v1/demo/session/extend",
"/api/v1/demo/session/destroy",
"/api/v1/demo/sessions",
"/api/v1/demo/stats",
"/api/v1/demo/operations",
]
if any(request.url.path.startswith(path) or request.url.path == path for path in demo_service_paths):
@@ -204,7 +203,7 @@ class DemoMiddleware(BaseHTTPMiddleware):
try:
async with httpx.AsyncClient(timeout=5.0) as client:
response = await client.get(
f"{self.demo_session_url}/api/demo/session/{session_id}"
f"{self.demo_session_url}/api/v1/demo/sessions/{session_id}"
)
if response.status_code == 200:
return response.json()
@@ -215,13 +214,9 @@ class DemoMiddleware(BaseHTTPMiddleware):
async def _update_session_activity(self, session_id: str):
"""Update session activity timestamp"""
try:
async with httpx.AsyncClient(timeout=2.0) as client:
await client.post(
f"{self.demo_session_url}/api/demo/session/{session_id}/activity"
)
except Exception as e:
logger.debug("Failed to update activity", session_id=session_id, error=str(e))
# Note: Activity tracking is handled by the demo service internally
# No explicit endpoint needed - activity is updated on session access
pass
def _check_blocked_path(self, path: str) -> Optional[dict]:
"""Check if path is explicitly blocked for demo accounts"""