"""FastAPI application entry point.""" from contextlib import asynccontextmanager from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.config import settings from app.routers import auth, users, worlds, assets, avatar, world_content, internal from app.services.game_servers import supervisor @asynccontextmanager async def lifespan(app: FastAPI): """Application lifespan: startup and shutdown events.""" supervisor.start() yield await supervisor.shutdown() app = FastAPI( title=settings.APP_NAME, version=settings.APP_VERSION, description="Agentic Game Platform - Backend API", lifespan=lifespan, ) # CORS app.add_middleware( CORSMiddleware, allow_origins=settings.cors_origins_list, allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include routers app.include_router(auth.router, prefix="/api/auth", tags=["auth"]) app.include_router(users.router, prefix="/api/users", tags=["users"]) app.include_router(worlds.router, prefix="/api/worlds", tags=["worlds"]) app.include_router(world_content.router, prefix="/api/worlds", tags=["world-content"]) app.include_router(assets.router, prefix="/api/assets", tags=["assets"]) app.include_router(avatar.router, prefix="/api/avatar", tags=["avatar"]) app.include_router(internal.router, prefix="/api/internal", tags=["internal"]) @app.get("/api/health") async def health_check(): """Simple health check endpoint.""" return {"status": "ok", "app": settings.APP_NAME}