from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from contextlib import asynccontextmanager from app.database import init_db from app.routers import auth, users, wallet, bets, websocket @asynccontextmanager async def lifespan(app: FastAPI): # Startup await init_db() yield # Shutdown app = FastAPI( title="H2H Betting Platform API", description="Peer-to-peer betting platform MVP", version="1.0.0", lifespan=lifespan ) # CORS middleware app.add_middleware( CORSMiddleware, allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) # Include routers app.include_router(auth.router) app.include_router(users.router) app.include_router(wallet.router) app.include_router(bets.router) app.include_router(websocket.router) @app.get("/") async def root(): return {"message": "H2H Betting Platform API", "version": "1.0.0"} @app.get("/health") async def health(): return {"status": "healthy"}