refactor: split app structure
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from ..api_utils import file_meta, load_accounts, load_records
|
||||
from ..auth import verify_records_auth
|
||||
from ..config import (
|
||||
ACCOUNTS_PATH,
|
||||
CLASSNOTES_PATH,
|
||||
COURSE_SUMMARIES_ROOT,
|
||||
COURSE_SUMMARY_STATE_PATH,
|
||||
OPERATION_LOGS_PATH,
|
||||
)
|
||||
from ..data import account_summary
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/api/health")
|
||||
def health(_user: str = Depends(verify_records_auth)):
|
||||
records = load_records()
|
||||
accounts = load_accounts()
|
||||
return {
|
||||
"ok": True,
|
||||
"classnotes": file_meta(CLASSNOTES_PATH),
|
||||
"accounts": file_meta(ACCOUNTS_PATH),
|
||||
"course_summaries": file_meta(COURSE_SUMMARIES_ROOT),
|
||||
"course_summary_state": file_meta(COURSE_SUMMARY_STATE_PATH),
|
||||
"operation_logs": file_meta(OPERATION_LOGS_PATH),
|
||||
"records_count": len(records),
|
||||
"accounts_count": len(accounts),
|
||||
"account_summary": account_summary(accounts),
|
||||
}
|
||||
Reference in New Issue
Block a user