This commit is contained in:
JMARyA 2024-08-17 10:45:10 +02:00
parent 7e6b65392e
commit 66b2a959d7
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
5 changed files with 157 additions and 2 deletions

View file

@ -10,6 +10,7 @@ pub mod album;
pub mod artist;
pub mod event;
pub mod playlist;
pub mod search;
pub mod track;
pub mod user;

View file

@ -20,7 +20,7 @@ use super::ToAPI;
#[get("/playlists")]
pub async fn playlists_route(u: User) -> FallibleApiResponse {
let mut playlists = vec![
json!({"id": "recent", "name": "Recently Played"}),
json!({"id": "recents", "name": "Recently Played"}),
json!({"id": "recentlyAdded", "name": "Recently Added"}),
];

12
src/route/search.rs Normal file
View file

@ -0,0 +1,12 @@
use super::api_error;
use super::FallibleApiResponse;
use mongodb::bson::doc;
use rocket::get;
use serde_json::json;
#[get("/search?<query>")]
pub async fn search_route(query: String) -> FallibleApiResponse {
Ok(json!(crate::library::search::search_for(query)
.await
.ok_or_else(|| api_error("Search failed"))?))
}