// src/route.rs pub mod handlers; use axum::{middleware, routing::{get, post}, Router}; use crate::{state::AppState, auth}; pub fn router(app_state: AppState) -> Router { Router::new() // Public routes (no auth required) .route("/api/health", get(handlers::health_handler)) .route("/api/auth/register", post(auth::handlers::register_handler)) .route("/api/auth/login", post(auth::handlers::login_handler)) // Protected routes (auth required) .route("/api/auth/me", get(auth::handlers::me_handler)) .route("/api/consent/:bank/:user_id", post(handlers::create_consent_handler) .get(handlers::get_consent_handler) ) .route("/api/accounts/:bank/:user_id", get(handlers::get_accounts_handler) ) .route("/api/transactions/:bank/:user_id/:account_id", get(handlers::get_transactions_handler) ) .layer(middleware::from_fn(auth::auth_middleware)) .with_state(app_state) }