pub mod handlers; pub mod services; pub mod types; use axum::{ routing::{get, post, put}, Router, }; use sqlx::PgPool; pub fn create_routes(pool: PgPool) -> Router { Router::new() // ========== Auction Routes ========== .route( "/auctions", post(handlers::auctions::insert_auction_handler), ) // Get auction by PDA .route( "/auctions/:auction_pda", get(handlers::auctions::select_auction_by_pda_handler), ) .route( "/auctions/status", put(handlers::auctions::update_auction_status_handler), ) .route( "/auctions/clearing-price", put(handlers::auctions::update_auction_clearing_price_handler), ) .route( "/auctions/bids/increment", put(handlers::auctions::increment_auction_bids_handler), ) .route( "/auctions/bids/decrement", put(handlers::auctions::decrement_auction_bids_handler), ) .route( "/auctions/local-admin/:local_admin", get(handlers::auctions::select_auctions_by_local_admin_handler), ) .route( "/auctions/status/:status", get(handlers::auctions::select_auctions_by_status_handler), ) .route( "/auctions/active", get(handlers::auctions::select_active_auctions_handler), ) .route( "/auctions/all", get(handlers::auctions::select_all_auctions_handler), ) // ========== Bid Routes ========== .route("/bids", post(handlers::bids::insert_bid_handler)) .route( "/bids/:bid_id", get(handlers::bids::select_bid_by_id_handler), ) .route( "/bids/hash/:bid_hash", get(handlers::bids::select_bid_by_hash_handler), ) .route( "/bids/status", put(handlers::bids::update_bid_status_handler), ) .route( "/bids/amount", put(handlers::bids::update_bid_amount_handler), ) .route( "/bids/auction/:auction_pda", get(handlers::bids::select_bids_by_auction_handler), ) .route( "/bids/company/:company_pubkey", get(handlers::bids::select_bids_by_company_handler), ) .route( "/bids/status/:status", get(handlers::bids::select_bids_by_status_handler), ) .route( "/bids/auction/:auction_pda/active", get(handlers::bids::select_active_bids_by_auction_handler), ) // ========== Auction Participation Routes ========== .route( "/participations", post(handlers::participations::insert_auction_participation_handler), ) .route( "/participations/leave", put(handlers::participations::update_auction_participation_left_handler), ) .route( "/participations/auction/:auction_pda", get(handlers::participations::select_participations_by_auction_handler), ) .route( "/participations/company/:company_pubkey", get(handlers::participations::select_participations_by_company_handler), ) .route( "/participations/auction/:auction_pda/active", get(handlers::participations::select_active_participations_by_auction_handler), ) // ========== Auction Settlement Routes ========== .route( "/settlements", post(handlers::settlements::insert_auction_settlement_handler), ) .route( "/settlements/:settlement_id", get(handlers::settlements::select_settlement_by_id_handler), ) .route( "/settlements/auction/:auction_pda", get(handlers::settlements::select_settlements_by_auction_handler), ) .route( "/settlements/company/:company_pubkey", get(handlers::settlements::select_settlements_by_company_handler), ) .route( "/settlements/bid/:bid_id", get(handlers::settlements::select_settlement_by_bid_handler), ) .route( "/settlements/all", get(handlers::settlements::select_all_settlements_handler), ) .with_state(pool) }