from fastapi import FastAPI, APIRouter from fastapi.middleware.cors import CORSMiddleware from app.core.config import settings from app.api.v1.endpoints import health, items # Create FastAPI app app = FastAPI( title=settings.PROJECT_NAME, description=settings.DESCRIPTION, version=settings.VERSION, openapi_url=f"{settings.API_V1_STR}/openapi.json", docs_url="/docs", redoc_url="/redoc", ) # Set up CORS if settings.BACKEND_CORS_ORIGINS: app.add_middleware( CORSMiddleware, allow_origins=[str(origin) for origin in settings.BACKEND_CORS_ORIGINS], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Create API router api_router = APIRouter() # Include routers from endpoints api_router.include_router(health.router, prefix="/health", tags=["health"]) api_router.include_router(items.router, prefix="/items", tags=["items"]) # Add API router to app app.include_router(api_router, prefix=settings.API_V1_STR)