mod app;
#[tokio::main]
async fn main() {
let port = std::env::var("PORT").unwrap_or_else(|_| "3000".into());
let config = match app::Config::from_env() {
Ok(config) => config,
Err(message) => {
eprintln!("configuration error: {message}");
std::process::exit(2);
}
};
let base = std::env::var("BASE_URL").unwrap_or_else(|_| format!("http://localhost:{port}"));
let app = match app::build(app::Config {
base_url: base,
..config
})
.await
{
Ok(app) => app,
Err(e) => {
eprintln!("cannot prepare the data directory: {e}");
std::process::exit(1);
}
};
app.run(&format!("0.0.0.0:{port}")).await.unwrap();
}