import logging from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from app.api.routes_characters import router as characters_router from app.api.routes_games import router as games_router from app.api.ws_game import router as ws_router from app.auth.users import auth_backend, fastapi_users from app.config import settings from app.schemas.user import UserCreate, UserRead, UserUpdate logging.basicConfig(level=logging.INFO, format="%(levelname)s:%(name)s:%(message)s") app = FastAPI(title="DungeonsDragons") app.add_middleware( CORSMiddleware, allow_origins=[settings.frontend_origin], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router( fastapi_users.get_auth_router(auth_backend), prefix="/auth/jwt", tags=["auth"] ) app.include_router( fastapi_users.get_register_router(UserRead, UserCreate), prefix="/auth", tags=["auth"] ) app.include_router( fastapi_users.get_reset_password_router(), prefix="/auth", tags=["auth"] ) app.include_router( fastapi_users.get_users_router(UserRead, UserUpdate), prefix="/users", tags=["users"] ) app.include_router(games_router) app.include_router(characters_router) app.include_router(ws_router) @app.get("/health") async def health() -> dict[str, str]: return {"status": "ok"}