fixing DQ issues
This commit is contained in:
@@ -1,4 +1,12 @@
|
||||
# app/core/config.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic_settings import \
|
||||
@@ -6,6 +14,8 @@ from pydantic_settings import \
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
"""Settings class inheriting from BaseSettings that allows values to be overridden by environment variables."""
|
||||
|
||||
# Project information
|
||||
project_name: str = "Ecommerce Backend API with Marketplace Support"
|
||||
description: str = "Advanced product management system with JWT authentication"
|
||||
|
||||
@@ -1,3 +1,14 @@
|
||||
# app/core/database.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import declarative_base, sessionmaker
|
||||
|
||||
@@ -8,13 +19,18 @@ SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)
|
||||
|
||||
Base = declarative_base()
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
# Database dependency with connection pooling
|
||||
|
||||
|
||||
def get_db():
|
||||
"""Get database object."""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
yield db
|
||||
except Exception as e:
|
||||
logger.error(f"Health check failed: {e}")
|
||||
db.rollback()
|
||||
raise
|
||||
finally:
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
# app/core/lifespan.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
@@ -16,7 +25,7 @@ auth_manager = AuthManager()
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Application lifespan events"""
|
||||
"""Application lifespan events."""
|
||||
# Startup
|
||||
app_logger = setup_logging() # Configure logging first
|
||||
app_logger.info("Starting up ecommerce API")
|
||||
@@ -43,7 +52,7 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
|
||||
def create_indexes():
|
||||
"""Create database indexes"""
|
||||
"""Create database indexes."""
|
||||
with engine.connect() as conn:
|
||||
try:
|
||||
# User indexes
|
||||
|
||||
@@ -1,4 +1,12 @@
|
||||
# app/core/logging.py
|
||||
"""Summary description ....
|
||||
|
||||
This module provides classes and functions for:
|
||||
- ....
|
||||
- ....
|
||||
- ....
|
||||
"""
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -7,8 +15,7 @@ from app.core.config import settings
|
||||
|
||||
|
||||
def setup_logging():
|
||||
"""Configure application logging with file and console handlers"""
|
||||
|
||||
"""Configure application logging with file and console handlers."""
|
||||
# Create logs directory if it doesn't exist
|
||||
log_file = Path(settings.log_file)
|
||||
log_file.parent.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user