Create the frontend receipes page to use real API
This commit is contained in:
@@ -257,6 +257,22 @@ async def proxy_tenant_deliveries(request: Request, tenant_id: str = Path(...),
|
||||
target_path = f"/api/v1/tenants/{tenant_id}/deliveries{path}".rstrip("/")
|
||||
return await _proxy_to_suppliers_service(request, target_path, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# TENANT-SCOPED RECIPES SERVICE ENDPOINTS
|
||||
# ================================================================
|
||||
|
||||
@router.api_route("/{tenant_id}/recipes", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
|
||||
async def proxy_tenant_recipes_base(request: Request, tenant_id: str = Path(...)):
|
||||
"""Proxy tenant recipes requests to recipes service (base path)"""
|
||||
target_path = f"/api/v1/tenants/{tenant_id}/recipes"
|
||||
return await _proxy_to_recipes_service(request, target_path, tenant_id=tenant_id)
|
||||
|
||||
@router.api_route("/{tenant_id}/recipes/{path:path}", methods=["GET", "POST", "PUT", "DELETE", "OPTIONS"])
|
||||
async def proxy_tenant_recipes_with_path(request: Request, tenant_id: str = Path(...), path: str = ""):
|
||||
"""Proxy tenant recipes requests to recipes service (with additional path)"""
|
||||
target_path = f"/api/v1/tenants/{tenant_id}/recipes/{path}".rstrip("/")
|
||||
return await _proxy_to_recipes_service(request, target_path, tenant_id=tenant_id)
|
||||
|
||||
# ================================================================
|
||||
# PROXY HELPER FUNCTIONS
|
||||
# ================================================================
|
||||
@@ -301,6 +317,10 @@ async def _proxy_to_suppliers_service(request: Request, target_path: str, tenant
|
||||
"""Proxy request to suppliers service"""
|
||||
return await _proxy_request(request, target_path, settings.SUPPLIERS_SERVICE_URL, tenant_id=tenant_id)
|
||||
|
||||
async def _proxy_to_recipes_service(request: Request, target_path: str, tenant_id: str = None):
|
||||
"""Proxy request to recipes service"""
|
||||
return await _proxy_request(request, target_path, settings.RECIPES_SERVICE_URL, tenant_id=tenant_id)
|
||||
|
||||
async def _proxy_request(request: Request, target_path: str, service_url: str, tenant_id: str = None):
|
||||
"""Generic proxy function with enhanced error handling"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user