pass_manager/src/main.rs

27 lines
740 B
Rust
Raw Normal View History

2023-04-24 17:48:34 +00:00
mod entity;
mod errors;
2023-04-27 13:25:23 +00:00
mod handlers;
mod models;
2023-04-24 17:48:34 +00:00
2023-04-27 13:25:23 +00:00
use anyhow::{Error, Result};
2023-04-24 17:48:34 +00:00
use dotenv::dotenv;
2023-04-27 13:25:23 +00:00
use handlers::get_dispatcher;
use migration::{Migrator, MigratorTrait};
use sea_orm::Database;
2023-05-03 18:08:14 +00:00
use std::{env, future::Future, pin::Pin};
type PinnedFuture<'a, T> = Pin<Box<dyn Future<Output = T> + Send + 'a>>;
2023-04-24 17:48:34 +00:00
#[tokio::main]
2023-04-27 13:25:23 +00:00
async fn main() -> Result<()> {
2023-04-24 17:48:34 +00:00
let _ = dotenv();
pretty_env_logger::init();
let token = env::var("TOKEN").expect("expected TOKEN in the enviroment");
let database_url = env::var("DATABASE_URL").expect("expected DATABASE_URL in the enviroment");
2023-04-27 13:25:23 +00:00
let db = Database::connect(database_url).await?;
Migrator::up(&db, None).await?;
get_dispatcher(token, db).dispatch().await;
Ok(())
2023-04-23 17:54:16 +00:00
}