from __future__ import annotations

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from .config import settings
from .database import Base, engine
from .routes.auth import router as auth_router
from .routes.games import router as games_router
from .routes.health import router as health_router
from .routes.media import router as media_router
from .routes.teamsnap import router as teamsnap_router

Base.metadata.create_all(bind=engine)

app = FastAPI(title=settings.app_name)
app.state.settings = settings
app.add_middleware(
    CORSMiddleware,
    allow_origins=settings.backend_cors_origins,
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.include_router(health_router)
app.include_router(auth_router)
app.include_router(media_router)
app.include_router(games_router)
app.include_router(teamsnap_router)
