Refactor code structure for improved readability and maintainability

This commit is contained in:
JSC
2025-07-27 14:24:11 +02:00
parent 0f605d7ed1
commit 2e87ff9927
8 changed files with 388 additions and 65 deletions

View File

@@ -1,6 +1,7 @@
from collections.abc import AsyncGenerator
from contextlib import asynccontextmanager
import socketio
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
@@ -8,6 +9,7 @@ from app.api import api_router
from app.core.database import init_db
from app.core.logging import get_logger, setup_logging
from app.middleware.logging import LoggingMiddleware
from app.services.socket import socket_manager
@asynccontextmanager
@@ -25,7 +27,7 @@ async def lifespan(_app: FastAPI) -> AsyncGenerator[None, None]:
logger.info("Shutting down application")
def create_app() -> FastAPI:
def create_app():
"""Create and configure the FastAPI application."""
app = FastAPI(lifespan=lifespan)
@@ -43,7 +45,8 @@ def create_app() -> FastAPI:
# Include API routes
app.include_router(api_router)
return app
# Create Socket.IO app with fallback to FastAPI app
return socketio.ASGIApp(socket_manager.sio, app)
app = create_app()