diff options
author | metamuffin <metamuffin@disroot.org> | 2025-02-06 16:52:46 +0100 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-02-06 16:52:46 +0100 |
commit | 0ce64a50b763d2b19f5ca254233370418f4b7658 (patch) | |
tree | fe1587d38c77180b0c7fa4911d416605e5d6c6e3 /common/src | |
parent | 87ebdede17007b626b1275c66dde1e5aefd6cddc (diff) | |
download | jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.bz2 jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.zst |
add json capability to most useful endpoints
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/api.rs | 36 | ||||
-rw-r--r-- | common/src/lib.rs | 1 |
2 files changed, 37 insertions, 0 deletions
diff --git a/common/src/api.rs b/common/src/api.rs new file mode 100644 index 0000000..d0b1db7 --- /dev/null +++ b/common/src/api.rs @@ -0,0 +1,36 @@ +/* + This file is part of jellything (https://codeberg.org/metamuffin/jellything) + which is licensed under the GNU Affero General Public License (version 3); see /COPYING. + Copyright (C) 2025 metamuffin <metamuffin.org> +*/ + +use crate::{user::NodeUserData, Node}; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +#[derive(Serialize, Deserialize)] +pub struct ApiNodeResponse { + pub parents: Vec<(Arc<Node>, NodeUserData)>, + pub children: Vec<(Arc<Node>, NodeUserData)>, + pub node: Arc<Node>, + pub userdata: NodeUserData, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiSearchResponse { + pub count: usize, + pub results: Vec<(Arc<Node>, NodeUserData)>, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiItemsResponse { + pub count: usize, + pub pages: usize, + pub items: Vec<(Arc<Node>, NodeUserData)>, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiHomeResponse { + pub toplevel: Vec<(Arc<Node>, NodeUserData)>, + pub categories: Vec<(String, Vec<(Arc<Node>, NodeUserData)>)>, +} diff --git a/common/src/lib.rs b/common/src/lib.rs index 4b67054..74476fe 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -3,6 +3,7 @@ which is licensed under the GNU Affero General Public License (version 3); see /COPYING. Copyright (C) 2025 metamuffin <metamuffin.org> */ +pub mod api; pub mod config; pub mod helpers; pub mod r#impl; |