0d12f7dfeat: config from env and SQLite pool in app context1mo | 1 | mod application; |
| 2 | mod infrastructure; |
| 3 | |
| 4 | use application::AppConfig; |
| 5 | use topcoat::router::{Router, RouterBuilderDiscoverExt}; |
e6f4874feat: topcoat skeleton serving a page1mo | 6 | |
| 7 | #[tokio::main] |
0d12f7dfeat: config from env and SQLite pool in app context1mo | 8 | async fn main() -> Result<(), Box<dyn std::error::Error>> { |
| 9 | dotenvy::dotenv().ok(); |
e6f4874feat: topcoat skeleton serving a page1mo | 10 | |
0d12f7dfeat: config from env and SQLite pool in app context1mo | 11 | let config = AppConfig::from_env()?; |
| 12 | let pool = infrastructure::database::connect(&config.database_url).await?; |
| 13 | |
| 14 | let router = Router::builder() |
| 15 | .discover() |
| 16 | .app_context(config) |
| 17 | .app_context(pool) |
| 18 | .build(); |
| 19 | |
| 20 | topcoat::start(router).await?; |
e6f4874feat: topcoat skeleton serving a page1mo | 21 | |
0d12f7dfeat: config from env and SQLite pool in app context1mo | 22 | Ok(()) |
| 23 | } |