diff --git a/src/fabledassistant/app.py b/src/fabledassistant/app.py index 40a7a15..333ab55 100644 --- a/src/fabledassistant/app.py +++ b/src/fabledassistant/app.py @@ -27,6 +27,7 @@ from fabledassistant.routes.profile import profile_bp from fabledassistant.routes.knowledge import knowledge_bp from fabledassistant.routes.rulebooks import rulebooks_bp from fabledassistant.routes.trash import trash_bp +from fabledassistant.routes.dashboard import dashboard_bp from fabledassistant.mcp import mount_mcp STATIC_DIR = Path(__file__).parent / "static" @@ -87,6 +88,7 @@ def create_app() -> Quart: app.register_blueprint(knowledge_bp) app.register_blueprint(rulebooks_bp) app.register_blueprint(trash_bp) + app.register_blueprint(dashboard_bp) @app.before_request async def before_request(): diff --git a/src/fabledassistant/routes/dashboard.py b/src/fabledassistant/routes/dashboard.py new file mode 100644 index 0000000..f1b6b7b --- /dev/null +++ b/src/fabledassistant/routes/dashboard.py @@ -0,0 +1,13 @@ +"""Dashboard REST endpoint — the aggregated landing payload.""" +from quart import Blueprint, g, jsonify + +from fabledassistant.auth import login_required +from fabledassistant.services.dashboard import build_dashboard + +dashboard_bp = Blueprint("dashboard", __name__, url_prefix="/api/dashboard") + + +@dashboard_bp.get("") +@login_required +async def get_dashboard(): + return jsonify(await build_dashboard(g.user.id)) diff --git a/tests/test_routes_dashboard.py b/tests/test_routes_dashboard.py new file mode 100644 index 0000000..e94d452 --- /dev/null +++ b/tests/test_routes_dashboard.py @@ -0,0 +1,18 @@ +"""Structural tests for the dashboard blueprint.""" + + +def test_dashboard_blueprint_registered(): + from fabledassistant.routes.dashboard import dashboard_bp + assert dashboard_bp.name == "dashboard" + assert dashboard_bp.url_prefix == "/api/dashboard" + + +def test_dashboard_blueprint_registered_in_app(): + from fabledassistant.app import create_app + app = create_app() + assert "dashboard" in app.blueprints + + +def test_dashboard_handler_callable(): + from fabledassistant.routes import dashboard as dashboard_routes + assert callable(dashboard_routes.get_dashboard)