aboutsummaryrefslogtreecommitdiff
path: root/common/src/api.rs
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-02-06 16:52:46 +0100
committermetamuffin <metamuffin@disroot.org>2025-02-06 16:52:46 +0100
commit0ce64a50b763d2b19f5ca254233370418f4b7658 (patch)
treefe1587d38c77180b0c7fa4911d416605e5d6c6e3 /common/src/api.rs
parent87ebdede17007b626b1275c66dde1e5aefd6cddc (diff)
downloadjellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar
jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.bz2
jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.zst
add json capability to most useful endpoints
Diffstat (limited to 'common/src/api.rs')
-rw-r--r--common/src/api.rs36
1 files changed, 36 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)>)>,
+}