diff options
Diffstat (limited to 'server/src/routes/api/mod.rs')
-rw-r--r-- | server/src/routes/api/mod.rs | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/server/src/routes/api/mod.rs b/server/src/routes/api/mod.rs index cc87525..23f313f 100644 --- a/server/src/routes/api/mod.rs +++ b/server/src/routes/api/mod.rs @@ -3,12 +3,13 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2023 metamuffin <metamuffin.org> */ - use super::ui::{ - account::{login_logic, LoginForm}, + account::{login_logic, session::AdminSession, LoginForm}, error::MyResult, }; use crate::database::Database; +use anyhow::{anyhow, Context}; +use jellycommon::Node; use rocket::{ get, http::MediaType, @@ -38,6 +39,20 @@ pub fn r_api_account_login(database: &State<Database>, data: Json<LoginForm>) -> Ok(json!(token)) } +#[get("/api/node_raw/<id>")] +pub fn r_api_node_raw( + _admin: AdminSession, + database: &State<Database>, + id: String, +) -> MyResult<Json<Node>> { + let node = database + .node + .get(&id) + .context("retrieving library node")? + .ok_or(anyhow!("node does not exist"))?; + Ok(Json(node)) +} + pub struct AcceptJson(bool); impl Deref for AcceptJson { type Target = bool; |