use library::Libary; mod library; mod route; use rocket::routes; use rocket::{http::Method, launch}; #[launch] async fn rocket() -> _ { let cors = rocket_cors::CorsOptions { allowed_origins: rocket_cors::AllowedOrigins::all(), allowed_methods: vec![Method::Get, Method::Post, Method::Options] .into_iter() .map(From::from) .collect(), allowed_headers: rocket_cors::AllowedHeaders::all(), allow_credentials: true, ..Default::default() } .to_cors() .expect("error creating CORS options"); let lib = Libary::new("/Users/angelo/Downloads/Music".into()).await; lib.rescan().await; rocket::build() .mount( "/", routes![ route::artist::artists_route, route::artist::artist_route, route::album::albums_route, route::album::album_route, route::track::track_route, route::track::track_audio_route, route::album::album_cover_route ], ) .manage(lib) .attach(cors) }