from fastapi import FastAPI from fastapi.middleware.cors import CORSMiddleware from contextlib import asynccontextmanager from app.database import init_db, close_db from app.routers import stores, documents, admin, openai_compat @asynccontextmanager async def lifespan(app: FastAPI): await init_db() yield await close_db() app = FastAPI( title="Vector Store API", version="1.0.0", lifespan=lifespan ) app.add_middleware( CORSMiddleware, allow_origins=["https://admin.vector.cosair.de"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"], ) app.include_router(stores.router, prefix="/stores", tags=["Stores"]) app.include_router(documents.router, prefix="/documents", tags=["Documents"]) app.include_router(admin.router, prefix="/admin", tags=["Admin"]) app.include_router(openai_compat.router, prefix="/v1", tags=["OpenAI Compatible"]) @app.get("/health") async def health(): return {"status": "ok"}