router.py 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. from fastapi import APIRouter
  2. from app.api.endpoints import (
  3. account,
  4. auth,
  5. common,
  6. config,
  7. node_configuration,
  8. email,
  9. notification,
  10. order,
  11. payment,
  12. plugin,
  13. product,
  14. provider,
  15. proxy,
  16. slot,
  17. sms,
  18. task,
  19. ticket,
  20. user,
  21. vas_task,
  22. webhook,
  23. )
  24. # 公共路由
  25. public_router = APIRouter()
  26. # 受保护路由
  27. protected_router = APIRouter()
  28. # 管理员级别路由
  29. admin_required_router = APIRouter()
  30. # 模块列表
  31. _modules = [
  32. account,
  33. auth,
  34. common,
  35. config,
  36. node_configuration,
  37. email,
  38. notification,
  39. order,
  40. payment,
  41. plugin,
  42. product,
  43. provider,
  44. proxy,
  45. slot,
  46. sms,
  47. task,
  48. ticket,
  49. user,
  50. vas_task,
  51. webhook,
  52. ]
  53. # 注册所有子模块路由
  54. for _mod in _modules:
  55. if hasattr(_mod, "public_router") and _mod.public_router.routes:
  56. public_router.include_router(_mod.public_router)
  57. if hasattr(_mod, "protected_router") and _mod.protected_router.routes:
  58. protected_router.include_router(_mod.protected_router)
  59. if hasattr(_mod, "admin_required_router") and _mod.admin_required_router.routes:
  60. admin_required_router.include_router(_mod.admin_required_router)