Files
h2h-prototype/backend/app/main.py

53 lines
1.2 KiB
Python

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, admin, sport_events, spread_bets, gamification, matches
@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.include_router(admin.router)
app.include_router(sport_events.router)
app.include_router(spread_bets.router)
app.include_router(gamification.router)
app.include_router(matches.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"}