From cb2f13d5b0c64039d691ec8f1f18501a3b9c3f3d Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Wed, 14 Jan 2026 09:37:07 -0300 Subject: [PATCH] Fix all duplicate route conflicts: combine methods and move UI routes to /api/ui/ --- src/analytics/insights.rs | 3 +-- src/billing/billing_ui.rs | 30 ++++++++++++++-------------- src/compliance/mod.rs | 27 ++++++------------------- src/dashboards/mod.rs | 42 +++++++++------------------------------ src/email/mod.rs | 3 +-- src/legal/mod.rs | 9 +++------ src/products/mod.rs | 16 +++++++-------- src/social/mod.rs | 10 +++------- 8 files changed, 46 insertions(+), 94 deletions(-) diff --git a/src/analytics/insights.rs b/src/analytics/insights.rs index 82ae22d3b..2229371c1 100644 --- a/src/analytics/insights.rs +++ b/src/analytics/insights.rs @@ -807,8 +807,7 @@ pub fn configure_insights_routes() -> Router> { .route("/api/insights/weekly", get(handle_get_weekly)) .route("/api/insights/trends", get(handle_get_trends)) .route("/api/insights/recommendations", get(handle_get_recommendations)) - .route("/api/insights/settings", get(handle_get_settings)) - .route("/api/insights/settings", put(handle_update_settings)) + .route("/api/insights/settings", get(handle_get_settings).put(handle_update_settings)) .route("/api/insights/focus-mode", put(handle_update_focus_mode)) .route("/api/insights/apps", get(handle_get_app_breakdown)) } diff --git a/src/billing/billing_ui.rs b/src/billing/billing_ui.rs index e582ac4f9..93390c4ec 100644 --- a/src/billing/billing_ui.rs +++ b/src/billing/billing_ui.rs @@ -50,21 +50,21 @@ fn format_currency(amount: f64, currency: &str) -> String { pub fn configure_billing_routes() -> Router> { Router::new() - .route("/api/billing/invoices", get(handle_invoices)) - .route("/api/billing/payments", get(handle_payments)) - .route("/api/billing/quotes", get(handle_quotes)) - .route("/api/billing/stats/pending", get(handle_stats_pending)) - .route("/api/billing/stats/revenue-month", get(handle_revenue_month)) - .route("/api/billing/stats/paid-month", get(handle_paid_month)) - .route("/api/billing/stats/overdue", get(handle_overdue)) - .route("/api/billing/search", get(handle_billing_search)) - .route("/api/billing/dashboard/metrics", get(handle_dashboard_metrics)) - .route("/api/billing/dashboard/spending-chart", get(handle_spending_chart)) - .route("/api/billing/dashboard/cost-breakdown", get(handle_cost_breakdown)) - .route("/api/billing/dashboard/quotas", get(handle_dashboard_quotas)) - .route("/api/billing/invoices/export", get(handle_invoices_export)) - .route("/api/billing/subscription/upgrade", post(handle_subscription_upgrade)) - .route("/api/billing/subscription/cancel", post(handle_subscription_cancel)) + .route("/api/ui/billing/invoices", get(handle_invoices)) + .route("/api/ui/billing/payments", get(handle_payments)) + .route("/api/ui/billing/quotes", get(handle_quotes)) + .route("/api/ui/billing/stats/pending", get(handle_stats_pending)) + .route("/api/ui/billing/stats/revenue-month", get(handle_revenue_month)) + .route("/api/ui/billing/stats/paid-month", get(handle_paid_month)) + .route("/api/ui/billing/stats/overdue", get(handle_overdue)) + .route("/api/ui/billing/search", get(handle_billing_search)) + .route("/api/ui/billing/dashboard/metrics", get(handle_dashboard_metrics)) + .route("/api/ui/billing/dashboard/spending-chart", get(handle_spending_chart)) + .route("/api/ui/billing/dashboard/cost-breakdown", get(handle_cost_breakdown)) + .route("/api/ui/billing/dashboard/quotas", get(handle_dashboard_quotas)) + .route("/api/ui/billing/invoices/export", get(handle_invoices_export)) + .route("/api/ui/billing/subscription/upgrade", post(handle_subscription_upgrade)) + .route("/api/ui/billing/subscription/cancel", post(handle_subscription_cancel)) .route("/api/admin/billing/quotas", put(handle_admin_billing_quotas)) .route("/api/admin/billing/alerts", put(handle_admin_billing_alerts)) } diff --git a/src/compliance/mod.rs b/src/compliance/mod.rs index 3e715af03..e25ecaf31 100644 --- a/src/compliance/mod.rs +++ b/src/compliance/mod.rs @@ -71,27 +71,12 @@ impl IntoResponse for ComplianceError { pub fn configure_compliance_routes() -> Router> { Router::new() - .route("/api/compliance/checks", get(handlers::handle_list_checks)) - .route("/api/compliance/checks", post(handlers::handle_run_check)) - .route( - "/api/compliance/checks/:check_id", - get(handlers::handle_get_check), - ) - .route("/api/compliance/issues", get(handlers::handle_list_issues)) - .route("/api/compliance/issues", post(handlers::handle_create_issue)) - .route( - "/api/compliance/issues/:issue_id", - put(handlers::handle_update_issue), - ) - .route("/api/compliance/audit", get(handlers::handle_list_audit_logs)) - .route( - "/api/compliance/audit", - post(handlers::handle_create_audit_log), - ) - .route( - "/api/compliance/training", - post(handlers::handle_create_training), - ) + .route("/api/compliance/checks", get(handlers::handle_list_checks).post(handlers::handle_run_check)) + .route("/api/compliance/checks/:check_id", get(handlers::handle_get_check)) + .route("/api/compliance/issues", get(handlers::handle_list_issues).post(handlers::handle_create_issue)) + .route("/api/compliance/issues/:issue_id", put(handlers::handle_update_issue)) + .route("/api/compliance/audit", get(handlers::handle_list_audit_logs).post(handlers::handle_create_audit_log)) + .route("/api/compliance/training", post(handlers::handle_create_training)) .route("/api/compliance/report", get(handlers::handle_get_report)) .route("/api/compliance/evidence", post(handlers::handle_upload_evidence)) } diff --git a/src/dashboards/mod.rs b/src/dashboards/mod.rs index 7319bf4ba..2ab6e885b 100644 --- a/src/dashboards/mod.rs +++ b/src/dashboards/mod.rs @@ -19,40 +19,16 @@ pub use types::*; pub fn configure_dashboards_routes() -> Router> { Router::new() - .route("/api/dashboards", get(handle_list_dashboards)) - .route("/api/dashboards", post(handle_create_dashboard)) + .route("/api/dashboards", get(handle_list_dashboards).post(handle_create_dashboard)) .route("/api/dashboards/templates", get(handle_get_templates)) - .route("/api/dashboards/:id", get(handle_get_dashboard)) - .route("/api/dashboards/:id", put(handle_update_dashboard)) - .route("/api/dashboards/:id", delete(handle_delete_dashboard)) + .route("/api/dashboards/:id", get(handle_get_dashboard).put(handle_update_dashboard).delete(handle_delete_dashboard)) .route("/api/dashboards/:id/widgets", post(handle_add_widget)) - .route( - "/api/dashboards/:id/widgets/:widget_id", - put(handle_update_widget), - ) - .route( - "/api/dashboards/:id/widgets/:widget_id", - delete(handle_delete_widget), - ) - .route( - "/api/dashboards/:id/widgets/:widget_id/data", - get(handle_get_widget_data), - ) - .route("/api/dashboards/sources", get(handle_list_data_sources)) - .route("/api/dashboards/sources", post(handle_create_data_source)) - .route( - "/api/dashboards/sources/:id/test", - post(handle_test_data_source), - ) - .route( - "/api/dashboards/sources/:id", - delete(handle_delete_data_source), - ) - .route("/api/dashboards/data-sources", get(handle_list_data_sources)) - .route("/api/dashboards/data-sources", post(handle_create_data_source)) - .route( - "/api/dashboards/data-sources/test", - post(handle_test_data_source_no_id), - ) + .route("/api/dashboards/:id/widgets/:widget_id", put(handle_update_widget).delete(handle_delete_widget)) + .route("/api/dashboards/:id/widgets/:widget_id/data", get(handle_get_widget_data)) + .route("/api/dashboards/sources", get(handle_list_data_sources).post(handle_create_data_source)) + .route("/api/dashboards/sources/:id/test", post(handle_test_data_source)) + .route("/api/dashboards/sources/:id", delete(handle_delete_data_source)) + .route("/api/dashboards/data-sources", get(handle_list_data_sources).post(handle_create_data_source)) + .route("/api/dashboards/data-sources/test", post(handle_test_data_source_no_id)) .route("/api/dashboards/query", post(handle_conversational_query)) } diff --git a/src/email/mod.rs b/src/email/mod.rs index 0eef557ec..01d785989 100644 --- a/src/email/mod.rs +++ b/src/email/mod.rs @@ -235,9 +235,8 @@ pub fn configure() -> Router> { .route(ApiUrls::EMAIL_SEARCH_HTMX, get(search_emails_htmx)) .route(ApiUrls::EMAIL_AUTO_RESPONDER_HTMX, post(save_auto_responder)) // Signatures API - .route("/api/email/signatures", get(list_signatures)) + .route("/api/email/signatures", get(list_signatures).post(create_signature)) .route("/api/email/signatures/default", get(get_default_signature)) - .route("/api/email/signatures", post(create_signature)) .route("/api/email/signatures/{id}", get(get_signature).put(update_signature).delete(delete_signature)) } diff --git a/src/legal/mod.rs b/src/legal/mod.rs index ac88ee452..1329feb01 100644 --- a/src/legal/mod.rs +++ b/src/legal/mod.rs @@ -926,14 +926,11 @@ impl Default for LegalService { pub fn configure_legal_routes() -> Router> { Router::new() .route("/api/legal/consent", post(handle_record_consent)) - .route("/api/legal/consent/:consent_id", get(handle_get_consent)) - .route("/api/legal/consent/:consent_id", put(handle_update_consent)) + .route("/api/legal/consent/:consent_id", get(handle_get_consent).put(handle_update_consent)) .route("/api/legal/consent/session", get(handle_get_consent_by_session)) .route("/api/legal/cookies/policy", get(handle_get_cookie_policy)) - .route("/api/legal/documents", get(handle_list_documents)) - .route("/api/legal/documents", post(handle_create_document)) - .route("/api/legal/documents/:slug", get(handle_get_document)) - .route("/api/legal/documents/:slug", put(handle_update_document)) + .route("/api/legal/documents", get(handle_list_documents).post(handle_create_document)) + .route("/api/legal/documents/:slug", get(handle_get_document).put(handle_update_document)) .route("/api/legal/gdpr/delete/:user_id", post(handle_request_data_deletion)) .route("/api/legal/gdpr/export/:user_id", post(handle_export_user_data)) } diff --git a/src/products/mod.rs b/src/products/mod.rs index aff270647..62687da6a 100644 --- a/src/products/mod.rs +++ b/src/products/mod.rs @@ -51,14 +51,14 @@ fn format_currency(amount: f64, currency: &str) -> String { pub fn configure_products_routes() -> Router> { Router::new() - .route("/api/products/items", get(handle_products_items)) - .route("/api/products/services", get(handle_products_services)) - .route("/api/products/pricelists", get(handle_products_pricelists)) - .route("/api/products/stats/total-products", get(handle_total_products)) - .route("/api/products/stats/total-services", get(handle_total_services)) - .route("/api/products/stats/pricelists", get(handle_total_pricelists)) - .route("/api/products/stats/active", get(handle_active_products)) - .route("/api/products/search", get(handle_products_search)) + .route("/api/ui/products/items", get(handle_products_items)) + .route("/api/ui/products/services", get(handle_products_services)) + .route("/api/ui/products/pricelists", get(handle_products_pricelists)) + .route("/api/ui/products/stats/total-products", get(handle_total_products)) + .route("/api/ui/products/stats/total-services", get(handle_total_services)) + .route("/api/ui/products/stats/pricelists", get(handle_total_pricelists)) + .route("/api/ui/products/stats/active", get(handle_active_products)) + .route("/api/ui/products/search", get(handle_products_search)) } async fn handle_products_items( diff --git a/src/social/mod.rs b/src/social/mod.rs index e278bb4d6..dee1eca61 100644 --- a/src/social/mod.rs +++ b/src/social/mod.rs @@ -1222,15 +1222,11 @@ pub fn configure_social_routes() -> Router> { .route("/api/ui/social/feed", get(handle_get_feed_html)) .route("/api/ui/social/suggested", get(handle_get_suggested_communities_html)) .route("/api/social/posts", post(handle_create_post)) - .route("/api/social/posts/{id}", get(handle_get_post)) - .route("/api/social/posts/{id}", put(handle_update_post)) - .route("/api/social/posts/{id}", delete(handle_delete_post)) + .route("/api/social/posts/{id}", get(handle_get_post).put(handle_update_post).delete(handle_delete_post)) .route("/api/social/posts/{id}/react", post(handle_add_reaction)) .route("/api/social/posts/{id}/react/{type}", delete(handle_remove_reaction)) - .route("/api/social/posts/{id}/comments", get(handle_get_comments)) - .route("/api/social/posts/{id}/comments", post(handle_add_comment)) - .route("/api/social/communities", get(handle_list_communities)) - .route("/api/social/communities", post(handle_create_community)) + .route("/api/social/posts/{id}/comments", get(handle_get_comments).post(handle_add_comment)) + .route("/api/social/communities", get(handle_list_communities).post(handle_create_community)) .route("/api/social/communities/{id}", get(handle_get_community)) .route("/api/social/communities/{id}/join", post(handle_join_community)) .route("/api/social/communities/{id}/leave", post(handle_leave_community))