File size: 1,311 Bytes
393bec4
 
 
 
 
fa1e61a
a32f9e3
97a5277
 
 
c841e94
a26f62e
fa1e61a
a32f9e3
 
 
 
 
 
 
 
 
 
 
 
 
 
fa1e61a
a26f62e
 
 
 
393bec4
a26f62e
97a5277
 
 
 
 
c841e94
97a5277
a32f9e3
a26f62e
fa1e61a
a32f9e3
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os

# Before any route imports that touch Chroma: disable product telemetry (avoids posthog capture() errors in logs).
os.environ.setdefault("ANONYMIZED_TELEMETRY", "FALSE")

from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware

from api.config import get_settings
from storage.audit_store import init_audit_db
from storage.job_store import init_jobs_db
from .routes import audit, ingest, jobs, query

_settings = get_settings()
app = FastAPI(
    title=_settings.app_name,
    version=_settings.app_version,
    description=_settings.app_description,
)

app.add_middleware(
    CORSMiddleware,
    allow_origins=["*"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

app.include_router(audit.router)
app.include_router(ingest.router)
app.include_router(jobs.router)
app.include_router(query.router)
app.include_router(query.legacy_query_router)


@app.on_event("startup")
async def startup() -> None:
    settings = get_settings()
    await init_audit_db(settings.audit_db_path)
    await init_jobs_db(settings.jobs_db_path)


@app.get("/health", tags=["Health"])
def health() -> dict[str, str]:
    settings = get_settings()
    return {
        "status": "ok",
        "app": settings.app_name,
        "version": settings.app_version,
    }