#[macro_use] extern crate rocket; #[macro_use] extern crate lazy_static; mod database; mod errors; mod serve; mod spotify; use tokio::runtime::Runtime; fn main() { let runtime = Runtime::new().unwrap(); let (client, connection) = runtime .block_on(tokio_postgres::connect( "host=127.0.0.1 user=spotify_intersect password=example dbname=track_db", tokio_postgres::NoTls, )) .expect("failed to connect to database"); unsafe { database::_client = Some(client); } runtime.spawn(async { connection.await.unwrap() }); runtime .block_on(database::initialize_db()) .expect("failed to initialize_db"); println!("connected with db"); runtime .block_on( rocket::ignite() .mount( "/", routes![ serve::token, serve::get_tracks, serve::match_users, serve::get_users, serve::create_lobby ], ) .launch(), ) .unwrap(); }