Fix all duplicate route conflicts: combine methods and move UI routes to /api/ui/

This commit is contained in:
Rodrigo Rodriguez (Pragmatismo) 2026-01-14 09:37:07 -03:00
parent 44a7f3eade
commit cb2f13d5b0
8 changed files with 46 additions and 94 deletions

View file

@ -807,8 +807,7 @@ pub fn configure_insights_routes() -> Router<Arc<AppState>> {
.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))
}

View file

@ -50,21 +50,21 @@ fn format_currency(amount: f64, currency: &str) -> String {
pub fn configure_billing_routes() -> Router<Arc<AppState>> {
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))
}

View file

@ -71,27 +71,12 @@ impl IntoResponse for ComplianceError {
pub fn configure_compliance_routes() -> Router<Arc<AppState>> {
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))
}

View file

@ -19,40 +19,16 @@ pub use types::*;
pub fn configure_dashboards_routes() -> Router<Arc<AppState>> {
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))
}

View file

@ -235,9 +235,8 @@ pub fn configure() -> Router<Arc<AppState>> {
.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))
}

View file

@ -926,14 +926,11 @@ impl Default for LegalService {
pub fn configure_legal_routes() -> Router<Arc<AppState>> {
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))
}

View file

@ -51,14 +51,14 @@ fn format_currency(amount: f64, currency: &str) -> String {
pub fn configure_products_routes() -> Router<Arc<AppState>> {
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(

View file

@ -1222,15 +1222,11 @@ pub fn configure_social_routes() -> Router<Arc<AppState>> {
.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))