magpie/app/api/routes.py
Alan Weinstock a863960266 feat: structured logging, frontend error toasts, stats bar (#14 #15 #16)
#14 — Structured logging
- app/core/logging_config.py: configure_logging() sets stdout handler
  with timestamped format; called at import time in main.py
- Global FastAPI exception_handler logs 500s with full traceback
- opportunities.py: logger added; create/approve/mark-posted/dismiss
  each emit an info line so failures are traceable

#15 — Frontend error handling
- frontend/src/composables/useToast.ts: shared toast composable
  (error/success/info, auto-dismiss, module-level singleton)
- frontend/src/components/ToastList.vue: fixed-position overlay,
  theme-aware, accessible (role=alert, aria-live=polite)
- OpportunitiesView: all 6 async actions have catch + toast.error()
- CampaignDetail: onMounted + all 6 mutation functions wrapped

#16 — Aggregate stats
- app/api/endpoints/stats.py: GET /api/v1/stats — single DB pass
  via GROUP BY; returns posts totals, 7-day count, top communities,
  platform breakdown, and opportunity queue counts
- frontend/src/components/StatsBar.vue: slim header bar above
  router-view; chips for posts ok/failed/week, queue pending/approved/
  posted, top community; hides gracefully on API error
2026-05-25 15:02:15 -07:00

15 lines
695 B
Python

from fastapi import FastAPI
from app.api.endpoints import blog, campaigns, opportunities, posts, reddit, scheduler, signals, stats, subs
def register_routes(app: FastAPI) -> None:
app.include_router(campaigns.router, prefix="/api/v1")
app.include_router(posts.router, prefix="/api/v1")
app.include_router(subs.router, prefix="/api/v1")
app.include_router(scheduler.router, prefix="/api/v1")
app.include_router(opportunities.router, prefix="/api/v1")
app.include_router(signals.router, prefix="/api/v1")
app.include_router(blog.router, prefix="/api/v1")
app.include_router(reddit.router, prefix="/api/v1")
app.include_router(stats.router, prefix="/api/v1")