From 8390c7f5100252956f97c0dc05aa6d7cce525d2c Mon Sep 17 00:00:00 2001 From: Lars Date: Wed, 18 Mar 2026 12:54:25 +0100 Subject: [PATCH] feat: add missing API endpoints - Add GET /api/insights/latest (returns latest 10 insights) - Add GET /api/auth/status (health check endpoint) These endpoints were called by frontend but returned 404, causing uncaught promise errors that blocked page loading. Co-Authored-By: Claude Opus 4.6 --- backend/main.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/backend/main.py b/backend/main.py index ca25b9e..c16dee1 100644 --- a/backend/main.py +++ b/backend/main.py @@ -644,6 +644,16 @@ def get_stats(x_profile_id: Optional[str]=Header(default=None), session: dict=De # ── AI Insights ─────────────────────────────────────────────────────────────── import httpx, json +@app.get("/api/insights/latest") +def get_latest_insights(x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)): + """Get latest AI insights across all scopes.""" + pid = get_pid(x_profile_id) + with get_db() as conn: + cur = get_cursor(conn) + cur.execute("SELECT * FROM ai_insights WHERE profile_id=%s ORDER BY created DESC LIMIT 10", (pid,)) + rows = cur.fetchall() + return [r2d(r) for r in rows] + @app.get("/api/ai/insights/{scope}") def get_ai_insight(scope: str, x_profile_id: Optional[str]=Header(default=None), session: dict=Depends(require_auth)): pid = get_pid(x_profile_id) @@ -1111,6 +1121,11 @@ def get_me(session: dict=Depends(require_auth)): pid = session['profile_id'] return get_profile(pid, session) +@app.get("/api/auth/status") +def auth_status(): + """Health check endpoint.""" + return {"status": "ok", "service": "mitai-jinkendo", "version": "v9b"} + @app.post("/api/auth/password-reset-request") @limiter.limit("3/minute") async def password_reset_request(req: PasswordResetRequest, request: Request):