refactor: switch to full auto-discovery for module API routes

- Enhanced route discovery system with ROUTE_CONFIG support for custom
  prefix, tags, and priority
- Added get_admin_api_routes() and get_vendor_api_routes() helpers that
  return routes sorted by priority
- Added fallback discovery for routes/{frontend}.py when routes/api/
  doesn't exist
- Updated CMS module with ROUTE_CONFIG (prefix: /content-pages,
  priority: 100) to register last for catch-all routes
- Moved customers routes from routes/ to routes/api/ directory
- Updated orders module to aggregate exception routers into main routers
- Removed manual module router imports from admin and vendor API init
  files, replaced with auto-discovery loop

Modules now auto-discovered: billing, inventory, orders, marketplace,
cms, customers, analytics, loyalty, messaging, monitoring, dev-tools

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-31 12:42:25 +01:00
parent 9fb3588030
commit db56b34894
14 changed files with 1230 additions and 155 deletions

View File

@@ -25,7 +25,15 @@ from app.modules.cms.schemas import (
from app.modules.cms.services import content_page_service
from models.database.user import User
# Route configuration for auto-discovery
ROUTE_CONFIG = {
"prefix": "/content-pages",
"tags": ["admin-content-pages"],
"priority": 100, # Register last (CMS has catch-all slug routes)
}
router = APIRouter()
admin_router = router # Alias for discovery compatibility
logger = logging.getLogger(__name__)