use super::api_error; use super::FallibleApiResponse; use mongodb::bson::doc; use rocket::*; use crate::library::Libary; /// Get all artists #[get("/artists")] pub async fn artists_route(lib: &State) -> FallibleApiResponse { let artists = lib.get_artists().await; Ok(serde_json::to_value(&artists).unwrap()) } #[get("/artist/")] pub async fn artist_route(id: &str, lib: &State) -> FallibleApiResponse { Ok(serde_json::to_value( &lib.get_artist_by_id(id) .await .ok_or_else(|| api_error("No artist with that ID found"))?, ) .unwrap()) }