#!/usr/bin/env python3
"""Check all registered routes in the Flask application"""

import sys
import os
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

from app import create_app

app = create_app()

print("REGISTERED ROUTES IN RATERIGHT:")
print("=" * 50)

routes = []
for rule in app.url_map.iter_rules():
    methods = ','.join(sorted(rule.methods - {'HEAD', 'OPTIONS'}))
    if methods:
        routes.append({
            'endpoint': rule.endpoint,
            'methods': methods,
            'path': str(rule)
        })

# Sort by path
routes.sort(key=lambda x: x['path'])

for route in routes:
    print(f"{route['methods']:6} {route['path']:<40} -> {route['endpoint']}")

print("\n" + "=" * 50)
print(f"Total routes: {len(routes)}")

# Check for specific routes
print("\nROUTE CHECK:")
print("-" * 30)
important_routes = ['/workers', '/login', '/auth/login', '/payments', '/api/payments']
for path in important_routes:
    found = any(path in r['path'] for r in routes)
    status = "✓ EXISTS" if found else "✗ MISSING"
    print(f"{status}: {path}")
