Skip to main content

scope/web/api/
mod.rs

1//! # Web API Handlers
2//!
3//! REST API endpoints mirroring CLI commands. Each handler accepts JSON
4//! request bodies matching CLI argument structures and returns JSON responses.
5
6pub mod address;
7pub mod address_book;
8pub mod compliance;
9pub mod config_status;
10pub mod crawl;
11pub mod discover;
12pub mod exchange;
13pub mod export;
14pub mod insights;
15pub mod market;
16pub mod token_health;
17pub mod tx;
18pub mod venues;
19
20use crate::web::AppState;
21use axum::Router;
22use std::sync::Arc;
23
24/// Registers all API routes under the `/api` prefix.
25pub fn routes(state: Arc<AppState>) -> Router<Arc<AppState>> {
26    Router::new()
27        .route("/address", axum::routing::post(address::handle))
28        .route("/tx", axum::routing::post(tx::handle))
29        .route("/insights", axum::routing::post(insights::handle))
30        .route("/crawl", axum::routing::post(crawl::handle))
31        .route("/discover", axum::routing::get(discover::handle))
32        .route("/token-health", axum::routing::post(token_health::handle))
33        .route("/market/summary", axum::routing::post(market::handle))
34        .route(
35            "/address-book/list",
36            axum::routing::get(address_book::handle_list),
37        )
38        .route(
39            "/address-book/add",
40            axum::routing::post(address_book::handle_add),
41        )
42        .route("/export", axum::routing::post(export::handle))
43        .route(
44            "/compliance/risk",
45            axum::routing::post(compliance::handle_risk),
46        )
47        .route("/config/status", axum::routing::get(config_status::handle))
48        .route("/config", axum::routing::post(config_status::handle_save))
49        .route("/venues", axum::routing::get(venues::handle))
50        .route("/exchange/snapshot", axum::routing::post(exchange::handle))
51        .with_state(state)
52}
53
54#[cfg(test)]
55mod tests {
56    use super::*;
57    use crate::chains::DefaultClientFactory;
58    use crate::config::Config;
59
60    #[test]
61    fn test_routes_construction() {
62        let config = Config::default();
63        let factory = DefaultClientFactory {
64            chains_config: config.chains.clone(),
65        };
66        let state = Arc::new(AppState { config, factory });
67        let _router = routes(state);
68        // If this doesn't panic, routes are properly constructed
69    }
70}