from contextlib import asynccontextmanager from fastapi import APIRouter, FastAPI from fastapi.middleware.cors import CORSMiddleware from app.config import settings from app.routers import jobs, predictions, samples, variants @asynccontextmanager async def lifespan(app: FastAPI): # Warm the model cache here once ml/ is wired in. yield app = FastAPI(title="rarelens API", version="0.1.0", lifespan=lifespan) app.add_middleware( CORSMiddleware, allow_origins=settings.cors_origins, allow_methods=["GET", "POST"], allow_headers=["content-type"], ) # The ingress forwards /api/* to this service unchanged, and local dev uses the same prefix. api = APIRouter(prefix="/api") api.include_router(samples.router, prefix="/samples", tags=["samples"]) api.include_router(jobs.router, prefix="/jobs", tags=["jobs"]) api.include_router(variants.router, prefix="/variants", tags=["variants"]) api.include_router(predictions.router, prefix="/predictions", tags=["predictions"]) app.include_router(api) @app.get("/health", tags=["ops"]) async def health() -> dict[str, str]: return {"status": "ok"}