-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (24 loc) · 951 Bytes
/
main.py
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
from fastapi import FastAPI
from app.Client import Client
from app.Settings import Settings
from app.get_context import Context, get_context
from api import todo, auth
ctx = get_context()
app = FastAPI(debug=ctx.get("settings").debug, title="ToDo App")
ctx.get("logger").debug(f'FastAPI Debug mode: {ctx.get("settings").debug}')
@app.get("/health", tags=["Health"])
def health(ctx: Context):
logger = ctx.get("logger")
logger.debug("Health check requested.")
return {"status": "OK"}
@app.get("/db-health", tags=["Health"])
async def db_health(ctx: Context):
logger: Settings = ctx.get("logger")
client: Client = ctx.get("client")
logger.debug("DB Health check requested")
documents_in_config_coll = (
client.get_config_collection().estimated_document_count({})
)
return {"status": "OK", "existingConfigs": documents_in_config_coll}
app.include_router(todo.router)
app.include_router(auth.router)