Update health API to pass authenticated users their info

This allows Khoj clients to get email address associated with
user's API token for display in client UX

In anonymous mode, default user information is passed
This commit is contained in:
Debanjum Singh Solanky 2024-01-17 11:48:18 +05:30
parent 4d30f7d1d9
commit 870af19ba4

View file

@ -554,6 +554,8 @@ async def extract_references_and_questions(
return compiled_references, inferred_queries, defiltered_query
@api.get("/health")
async def health_check():
return Response(status_code=200)
@api.get("/health", response_class=Response)
@requires(["authenticated"], status_code=200)
def health_check(request: Request) -> Response:
response_obj = {"email": request.user.object.email}
return Response(content=json.dumps(response_obj), media_type="application/json", status_code=200)