37 lines
1.0 KiB
Python
37 lines
1.0 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from app.core.database import engine, Base
|
|
from app.core.admin_bootstrap import bootstrap_admin
|
|
from app.api.routes import auth, users, admin, decks, collection
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await bootstrap_admin()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="MTG Deck Builder", version="1.0.0", lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(auth.router, prefix="/api/auth", tags=["auth"])
|
|
app.include_router(users.router, prefix="/api/users", tags=["users"])
|
|
app.include_router(admin.router, prefix="/api/admin", tags=["admin"])
|
|
app.include_router(decks.router, prefix="/api/decks", tags=["decks"])
|
|
app.include_router(collection.router, prefix="/api/collection", tags=["collection"])
|
|
|
|
|
|
@app.get("/api/health")
|
|
async def health():
|
|
return {"status": "ok"}
|