feat(bootstrap): composition root with Config + factory.rs
This commit is contained in:
25
crates/bootstrap/src/main.rs
Normal file
25
crates/bootstrap/src/main.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
mod config;
|
||||
mod factory;
|
||||
|
||||
use tower_http::cors::CorsLayer;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let cfg = config::Config::from_env();
|
||||
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
let infra = factory::build(&cfg).await;
|
||||
|
||||
let app = presentation::routes::router(&infra.fed_config)
|
||||
.with_state(infra.state)
|
||||
.layer(CorsLayer::permissive());
|
||||
|
||||
let addr = format!("0.0.0.0:{}", cfg.port);
|
||||
tracing::info!("Listening on {addr}");
|
||||
let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user