#![forbid(unsafe_code)]
#![warn(missing_docs)]

//! Shared API Library
//!
//! A comprehensive, reusable Rust library for building high-performance REST APIs
//! with common infrastructure patterns: configuration, authentication, metrics,
//! rate limiting, WebSocket support, and error handling.
//!
//! # Features
//!
//! - **Configuration** (`config`): TOML-based configuration with feature flags
//! - **Error Handling** (`error`): Unified API error types and responses
//! - **Health Checks** (`health`): Server health/status endpoints with uptime tracking
//! - **Authentication** (`auth`): API key and JWT authentication (optional feature: `auth`)
//! - **Metrics** (`metrics`): Prometheus metrics collection (optional feature: `metrics`)
//! - **Rate Limiting** (`rate_limit`): Token bucket-based rate limiting (optional feature: `rate-limit`)
//! - **WebSockets** (`websocket`): Real-time event broadcasting (optional feature: `websocket`)
//! - **Middleware** (`middleware`): Common middleware utilities (CORS, logging)
//!
//! # Example
//!
//! ```ignore
//! use shared_api_lib::config::ServerConfig;
//! use shared_api_lib::health;
//! use axum::{
//!     routing::get,
//!     Router,
//! };
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//!     let config = ServerConfig::load("config.toml")?;
//!     config.log_config();
//!
//!     let app = Router::new()
//!         .route("/health", get(health::health));
//!
//!     Ok(())
//! }
//! ```

pub mod config;
pub mod error;
pub mod health;
pub mod middleware;
pub mod state;

#[cfg(feature = "auth")]
pub mod auth;

#[cfg(feature = "metrics")]
pub mod metrics;

#[cfg(feature = "rate-limit")]
pub mod rate_limit;

#[cfg(feature = "websocket")]
pub mod websocket;

// Re-export commonly used types
pub use config::{ConfigError, ServerConfig};
pub use error::{ApiError, ApiResult};

#[cfg(feature = "auth")]
pub use auth::{ApiKey, AuthProvider};

#[cfg(feature = "metrics")]
pub use metrics::MetricsCollector;

#[cfg(feature = "rate-limit")]
pub use rate_limit::RateLimiter;
