2023-04-24 17:48:34 +00:00
|
|
|
mod entity;
|
2023-05-06 17:20:33 +00:00
|
|
|
mod errors;
|
2023-04-27 13:25:23 +00:00
|
|
|
mod handlers;
|
2023-05-05 18:29:58 +00:00
|
|
|
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-05-15 16:09:15 +00:00
|
|
|
use futures::future::BoxFuture as PinnedFuture;
|
2023-04-27 13:25:23 +00:00
|
|
|
use handlers::get_dispatcher;
|
|
|
|
use migration::{Migrator, MigratorTrait};
|
|
|
|
use sea_orm::Database;
|
2023-05-15 16:09:15 +00:00
|
|
|
use std::env;
|
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();
|
|
|
|
|
2023-05-06 17:20:33 +00:00
|
|
|
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
|
|
|
}
|