Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion backend/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from routes.plugins import router as plugins_router
from routes.export import router as export_router
from routes.settings import router as settings_router
from services.db_service import init_db
from services.db_service import init_db, get_db

logging.basicConfig(
level=logging.INFO,
Expand Down Expand Up @@ -90,3 +90,12 @@ async def root():
@app.get("/health", tags=["Health"])
async def health():
return {"status": "healthy"}

@app.get("/health/db", tags=["Health"])
async def db_health():
try:
with get_db() as conn:
conn.execute("SELECT 1")
return {"status": "healthy"}
except Exception:
return {"status": "unhealthy"}
5 changes: 5 additions & 0 deletions backend/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ def test_health():
assert r.json()["status"] == "healthy"


def test_db_health():
r = client.get("/health/db")
assert r.status_code == 200
assert r.json()["status"] == "healthy"

# ─── Sessions ────────────────────────────────────────────
def test_create_session():
r = client.post("/api/sessions/", json={"title": "Test Chat", "model": "llama3"})
Expand Down