complycore/backend/main.py

37 lines
960 B
Python

# backend/main.py
from fastapi import FastAPI
from fastapi.responses import JSONResponse
from sqlalchemy import text
from db.session import engine
from fastapi import Depends
from auth.jwt import get_current_user
app = FastAPI()
@app.get("/healthz")
def health_check():
return {"status": "ok"}
@app.get("/supabase-check")
def supabase_check():
try:
with engine.connect() as conn:
result = conn.execute(text("SELECT current_database(), current_user;"))
db, user = result.fetchone()
return {"status": "connected", "db": db, "user": user}
except Exception as e:
return JSONResponse(status_code=500, content={"status": "error", "error": str(e)})
@app.get("/me")
def me(current: dict = Depends(get_current_user)):
return {
"id": current["id"],
"email": current["email"],
"role": current["role"],
"tenant_id": current["tenant_id"],
}