Fix imports

This commit is contained in:
Urtzi Alfaro
2025-07-18 14:41:39 +02:00
parent a469f0c01d
commit 4073222888
30 changed files with 123 additions and 119 deletions

View File

@@ -7,7 +7,7 @@ Authentication API routes - Enhanced with proper metrics access
from fastapi import APIRouter, Depends, HTTPException, status, Request
from sqlalchemy.ext.asyncio import AsyncSession
import logging
import structlog
from app.core.database import get_db
from app.schemas.auth import (
@@ -18,7 +18,7 @@ from app.services.auth_service import AuthService
from app.core.security import security_manager
from shared.monitoring.decorators import track_execution_time, count_calls
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
router = APIRouter()
def get_metrics_collector(request: Request):

View File

@@ -5,7 +5,7 @@ User management API routes
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.ext.asyncio import AsyncSession
from typing import List
import logging
import structlog
from app.core.database import get_db
from app.schemas.auth import UserResponse, PasswordChangeRequest
@@ -13,7 +13,7 @@ from app.services.user_service import UserService
from app.core.auth import get_current_user
from app.models.users import User
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
router = APIRouter()
@router.get("/me", response_model=UserResponse)

View File

@@ -8,13 +8,13 @@ from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select
from jose import JWTError, jwt
import logging
import structlog
from app.core.config import settings
from app.core.database import get_db
from app.models.users import User
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
security = HTTPBearer()

View File

@@ -5,14 +5,14 @@
Database configuration for authentication service
"""
import logging
import structlog
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession, async_sessionmaker
from sqlalchemy.pool import NullPool
from app.core.config import settings
from shared.database.base import Base
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
# Create async engine
engine = create_async_engine(

View File

@@ -12,12 +12,12 @@ from datetime import datetime, timedelta
from typing import Optional, Dict, Any
import redis.asyncio as redis
from fastapi import HTTPException, status
import logging
import structlog
from app.core.config import settings
from shared.auth.jwt_handler import JWTHandler
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
# Initialize JWT handler
jwt_handler = JWTHandler(settings.JWT_SECRET_KEY, settings.JWT_ALGORITHM)

View File

@@ -2,7 +2,7 @@
Authentication Service Main Application - Fixed middleware issue
"""
import logging
import structlog
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse
@@ -17,7 +17,7 @@ from shared.monitoring.metrics import setup_metrics_early
# Setup logging first
setup_logging("auth-service", settings.LOG_LEVEL)
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
# Global variables for lifespan access
metrics_collector = None

View File

@@ -5,7 +5,7 @@
Authentication service business logic - Complete implementation
"""
import logging
import structlog
from datetime import datetime, timedelta, timezone
from typing import Optional, Dict, Any
from sqlalchemy.ext.asyncio import AsyncSession
@@ -18,7 +18,7 @@ from app.schemas.auth import UserRegistration, UserLogin, TokenResponse, UserRes
from app.core.security import security_manager
from app.services.messaging import publish_user_registered, publish_user_login
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
class AuthService:
"""Authentication service business logic"""

View File

@@ -4,9 +4,9 @@ Messaging service for auth service
"""
from shared.messaging.rabbitmq import RabbitMQClient
from app.core.config import settings
import logging
import structlog
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
# Single global instance
auth_publisher = RabbitMQClient(settings.RABBITMQ_URL, "auth-service")

View File

@@ -6,12 +6,12 @@ from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy import select, update, delete
from fastapi import HTTPException, status
from passlib.context import CryptContext
import logging
import structlog
from app.models.users import User
from app.core.config import settings
logger = logging.getLogger(__name__)
logger = structlog.get_logger()
# Password hashing
pwd_context = CryptContext(schemes=["bcrypt"], deprecated="auto")

View File

@@ -16,3 +16,4 @@ prometheus-client==0.17.1
python-json-logger==2.0.4
pytz==2023.3
python-logstash==0.4.8
structlog==23.2.0