backbone-banking 0.7.1

Cash & bank — bank/account master, statement import, reconciliation, and clearing postings (5th GL producer)
Documentation
//! HTTP route configuration
//!
//! Generated by metaphor-schema. Do not edit manually.
//!
//! This module provides consolidated Axum route configuration using backbone-core's
//! BackboneCrudHandler for all 12 standard Backbone CRUD endpoints per entity.

use axum::Router;
use std::sync::Arc;

use super::{
    bank_handler::create_bank_routes,
    bank_account_handler::create_bank_account_routes,
    bank_clearance_handler::create_bank_clearance_routes,
    bank_reconciliation_handler::create_bank_reconciliation_routes,
    bank_statement_import_handler::create_bank_statement_import_routes,
    bank_transaction_handler::create_bank_transaction_routes,
    fx_gain_loss_handler::create_fx_gain_loss_routes,
    reconcile_preset_handler::create_reconcile_preset_routes,
};

use crate::application::service::{
    BankService,
    BankAccountService,
    BankClearanceService,
    BankReconciliationService,
    BankStatementImportService,
    BankTransactionService,
    FxGainLossService,
    ReconcilePresetService,
};

/// Services collection for all CRUD endpoints
pub struct HttpServices {
    pub bank: Arc<BankService>,
    pub bank_account: Arc<BankAccountService>,
    pub bank_clearance: Arc<BankClearanceService>,
    pub bank_reconciliation: Arc<BankReconciliationService>,
    pub bank_statement_import: Arc<BankStatementImportService>,
    pub bank_transaction: Arc<BankTransactionService>,
    pub fx_gain_loss: Arc<FxGainLossService>,
    pub reconcile_preset: Arc<ReconcilePresetService>,
}

/// Configure all HTTP routes for this module using Axum and BackboneCrudHandler.
///
/// Each entity gets 12 standard Backbone CRUD endpoints:
/// 1. GET /api/v1/{collection} - List with pagination
/// 2. POST /api/v1/{collection} - Create
/// 3. GET /api/v1/{collection}/:id - Get by ID
/// 4. PUT /api/v1/{collection}/:id - Full update
/// 5. PATCH /api/v1/{collection}/:id - Partial update
/// 6. DELETE /api/v1/{collection}/:id - Soft delete
/// 7. POST /api/v1/{collection}/bulk - Bulk create
/// 8. POST /api/v1/{collection}/upsert - Upsert
/// 9. GET /api/v1/{collection}/trash - List deleted
/// 10. POST /api/v1/{collection}/:id/restore - Restore
/// 11. DELETE /api/v1/{collection}/empty - Empty trash
/// 12. GET /api/v1/{collection}/:id/deleted - Get deleted by ID
pub fn configure_routes(services: HttpServices) -> Router {
    Router::new()
        // Bank routes (12 Backbone endpoints)
        .merge(create_bank_routes(services.bank))
        // BankAccount routes (12 Backbone endpoints)
        .merge(create_bank_account_routes(services.bank_account))
        // BankClearance routes (12 Backbone endpoints)
        .merge(create_bank_clearance_routes(services.bank_clearance))
        // BankReconciliation routes (12 Backbone endpoints)
        .merge(create_bank_reconciliation_routes(services.bank_reconciliation))
        // BankStatementImport routes (12 Backbone endpoints)
        .merge(create_bank_statement_import_routes(services.bank_statement_import))
        // BankTransaction routes (12 Backbone endpoints)
        .merge(create_bank_transaction_routes(services.bank_transaction))
        // FxGainLoss routes (12 Backbone endpoints)
        .merge(create_fx_gain_loss_routes(services.fx_gain_loss))
        // ReconcilePreset routes (12 Backbone endpoints)
        .merge(create_reconcile_preset_routes(services.reconcile_preset))
}

/// Create an individual entity's routes (for modular configuration)
pub mod individual {
    use super::*;

    pub fn bank_routes(service: Arc<BankService>) -> Router {
        create_bank_routes(service)
    }

    pub fn bank_account_routes(service: Arc<BankAccountService>) -> Router {
        create_bank_account_routes(service)
    }

    pub fn bank_clearance_routes(service: Arc<BankClearanceService>) -> Router {
        create_bank_clearance_routes(service)
    }

    pub fn bank_reconciliation_routes(service: Arc<BankReconciliationService>) -> Router {
        create_bank_reconciliation_routes(service)
    }

    pub fn bank_statement_import_routes(service: Arc<BankStatementImportService>) -> Router {
        create_bank_statement_import_routes(service)
    }

    pub fn bank_transaction_routes(service: Arc<BankTransactionService>) -> Router {
        create_bank_transaction_routes(service)
    }

    pub fn fx_gain_loss_routes(service: Arc<FxGainLossService>) -> Router {
        create_fx_gain_loss_routes(service)
    }

    pub fn reconcile_preset_routes(service: Arc<ReconcilePresetService>) -> Router {
        create_reconcile_preset_routes(service)
    }

}