allframe_core/lib.rs
1//! # AllFrame Core
2//!
3//! The composable Rust API framework.
4//!
5//! AllFrame is the first Rust web framework designed, built, and evolved
6//! exclusively through Test-Driven Development (TDD).
7//!
8//! ## Quick Start
9//!
10//! ```rust,no_run
11//! use allframe_core::prelude::*;
12//!
13//! #[tokio::main]
14//! async fn main() {
15//! println!("AllFrame - One frame. Infinite transformations.");
16//! }
17//! ```
18
19#![deny(warnings)]
20#![deny(missing_docs)]
21#![deny(unsafe_code)]
22
23/// Clean Architecture enforcement
24#[cfg(feature = "di")]
25pub mod arch;
26
27/// CQRS + Event Sourcing
28#[cfg(feature = "cqrs")]
29pub mod cqrs;
30
31/// OpenTelemetry automatic instrumentation
32#[cfg(feature = "otel")]
33pub mod otel;
34
35/// Cache abstraction
36pub mod cache;
37
38/// Health check infrastructure
39pub mod health;
40
41/// Router module for protocol-agnostic request handling
42pub mod router;
43
44/// Graceful shutdown utilities
45pub mod shutdown;
46
47// ============================================================================
48// Re-exported dependencies
49// ============================================================================
50// These re-exports allow consumers to use common dependencies without adding
51// them explicitly to their Cargo.toml. This ensures version consistency and
52// reduces boilerplate in downstream crates.
53
54// ============================================================================
55// Re-exported macros
56// ============================================================================
57/// Re-export GrpcError derive macro for automatic tonic::Status conversion
58#[cfg(feature = "router-grpc")]
59pub use allframe_macros::GrpcError;
60/// Re-export async_graphql for GraphQL support
61#[cfg(feature = "router-graphql")]
62pub use async_graphql;
63/// Re-export async_graphql_parser for GraphQL parsing
64#[cfg(feature = "router-graphql")]
65pub use async_graphql_parser;
66/// Re-export async_trait for async trait definitions
67pub use async_trait;
68/// Re-export futures for async utilities
69#[cfg(feature = "router-grpc")]
70pub use futures;
71/// Re-export hyper for HTTP primitives
72pub use hyper;
73/// Re-export prost for protobuf support
74#[cfg(feature = "router-grpc")]
75pub use prost;
76/// Re-export prost_types for well-known protobuf types
77#[cfg(feature = "router-grpc")]
78pub use prost_types;
79/// Re-export serde for serialization
80pub use serde;
81/// Re-export serde_json for JSON handling
82pub use serde_json;
83/// Re-export tokio for async runtime
84pub use tokio;
85/// Re-export tokio_stream for async streams
86#[cfg(feature = "router-grpc")]
87pub use tokio_stream;
88/// Re-export tonic for gRPC support
89#[cfg(feature = "router-grpc")]
90pub use tonic;
91/// Re-export tonic_reflection for gRPC reflection
92#[cfg(feature = "router-grpc")]
93pub use tonic_reflection;
94/// Re-export tracing for observability
95#[cfg(feature = "otel")]
96pub use tracing;
97
98/// Prelude module for convenient imports
99///
100/// Commonly used imports for AllFrame applications
101pub mod prelude {
102 /// Re-export cache utilities
103 pub use crate::cache::{Cache, CacheConfig, CacheKey, MemoryCache};
104 /// Re-export health check utilities
105 pub use crate::health::{
106 Dependency, DependencyStatus, HealthCheck, HealthReport, HealthServer, OverallStatus,
107 SimpleHealthCheck,
108 };
109 pub use crate::router::{
110 GraphQLAdapter, GrpcAdapter, GrpcRequest, GrpcStatus, Method, ProtocolAdapter, RestAdapter,
111 RestRequest, RestResponse, RouteMetadata, Router, ToJsonSchema,
112 };
113 #[cfg(feature = "router")]
114 pub use crate::router::{GraphQLConfig, GrpcConfig, RestConfig, RouterConfig, ServerConfig};
115 /// Re-export shutdown utilities
116 pub use crate::shutdown::{GracefulShutdown, ShutdownSignal, ShutdownToken};
117 /// Re-export GrpcError for convenient error handling
118 #[cfg(feature = "router-grpc")]
119 pub use crate::GrpcError;
120}
121
122#[cfg(test)]
123mod tests {
124 #[test]
125 fn test_allframe_core_exists() {
126 // This test verifies the crate compiles
127 assert!(true);
128 }
129}