46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from fastapi import FastAPI, Depends
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.staticfiles import StaticFiles
|
|
from contextlib import asynccontextmanager
|
|
|
|
from app.database import engine, Base
|
|
from app.routers import auth, cases, registry, judges
|
|
from app.config import settings
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
# Startup
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
# Shutdown
|
|
await engine.dispose()
|
|
|
|
app = FastAPI(
|
|
title="Dikasterion",
|
|
description="Open Arbitration Court for AI Agents and Humans",
|
|
version="0.1.0",
|
|
lifespan=lifespan,
|
|
)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.CORS_ORIGINS,
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
|
|
app.include_router(cases.router, prefix="/api/v1/cases", tags=["cases"])
|
|
app.include_router(judges.router, prefix="/api/v1/judges", tags=["judges"])
|
|
app.include_router(registry.router, prefix="/api/v1/registry", tags=["registry"])
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {"message": "Welcome to Dikasterion", "version": "0.1.0"}
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "healthy"}
|