39 lines
1.2 KiB
Python
39 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, async_session
|
|
from app.routers import auth, scan
|
|
from app.routers import compare, profile, stats, achievements, shopping, share
|
|
from app.services.achievements import seed_achievements
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await init_db()
|
|
# Seed achievements
|
|
async with async_session() as db:
|
|
await seed_achievements(db)
|
|
yield
|
|
|
|
app = FastAPI(title="Aletheia API", version="0.2.0", lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:3080", "http://127.0.0.1:3080", "http://198.199.84.130:3080", "*"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(auth.router)
|
|
app.include_router(scan.router)
|
|
app.include_router(compare.router)
|
|
app.include_router(profile.router)
|
|
app.include_router(stats.router)
|
|
app.include_router(achievements.router)
|
|
app.include_router(shopping.router)
|
|
app.include_router(share.router)
|
|
|
|
@app.get("/api/health")
|
|
async def health():
|
|
return {"status": "ok", "app": "Aletheia API v0.2"}
|