diff options
Diffstat (limited to 'server/src/routes')
-rw-r--r-- | server/src/routes/api/mod.rs | 19 | ||||
-rw-r--r-- | server/src/routes/mod.rs | 3 |
2 files changed, 19 insertions, 3 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; diff --git a/server/src/routes/mod.rs b/server/src/routes/mod.rs index 6ebde33..86a55ac 100644 --- a/server/src/routes/mod.rs +++ b/server/src/routes/mod.rs @@ -4,7 +4,7 @@ Copyright (C) 2023 metamuffin <metamuffin.org> */ use crate::{database::Database, federation::Federation, routes::ui::error::MyResult}; -use api::{r_api_account_login, r_api_root, r_api_version}; +use api::{r_api_account_login, r_api_node_raw, r_api_root, r_api_version}; use base64::Engine; use jellybase::CONF; use jellyremuxer::RemuxerContext; @@ -112,6 +112,7 @@ pub fn build_rocket( r_api_version, r_api_account_login, r_api_root, + r_api_node_raw, ], ) } |