REFACTOR API gateway

This commit is contained in:
Urtzi Alfaro
2025-07-26 18:46:52 +02:00
parent e49893e10a
commit e4885db828
24 changed files with 1049 additions and 1080 deletions

View File

@@ -21,7 +21,7 @@ from app.core.security import SecurityManager
from shared.monitoring.decorators import track_execution_time
logger = structlog.get_logger()
router = APIRouter()
router = APIRouter(tags=["authentication"])
security = HTTPBearer(auto_error=False)
def get_metrics_collector(request: Request):

View File

@@ -21,7 +21,7 @@ from shared.auth.decorators import (
)
logger = structlog.get_logger()
router = APIRouter()
router = APIRouter(tags=["users"])
@router.get("/me", response_model=UserResponse)
async def get_current_user_info(
@@ -77,46 +77,4 @@ async def update_current_user(
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Failed to update user"
)
@router.post("/change-password")
async def change_password(
password_data: PasswordChange,
current_user: Dict[str, Any] = Depends(get_current_user_dep),
db: AsyncSession = Depends(get_db)
):
"""Change user password"""
try:
await UserService.change_password(
current_user.id,
password_data.current_password,
password_data.new_password,
db
)
return {"message": "Password changed successfully"}
except HTTPException:
raise
except Exception as e:
logger.error(f"Password change error: {e}")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Failed to change password"
)
@router.delete("/me")
async def delete_current_user(
current_user: Dict[str, Any] = Depends(get_current_user_dep),
db: AsyncSession = Depends(get_db)
):
"""Delete current user account"""
try:
await UserService.delete_user(current_user.id, db)
return {"message": "User account deleted successfully"}
except HTTPException:
raise
except Exception as e:
logger.error(f"Delete user error: {e}")
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail="Failed to delete user account"
)