aboutsummaryrefslogtreecommitdiff
path: root/common
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
parent87ebdede17007b626b1275c66dde1e5aefd6cddc (diff)
downloadjellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar
jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.bz2
jellything-0ce64a50b763d2b19f5ca254233370418f4b7658.tar.zst
add json capability to most useful endpoints
Diffstat (limited to 'common')
-rw-r--r--common/Cargo.toml2
-rw-r--r--common/src/api.rs36
-rw-r--r--common/src/lib.rs1
3 files changed, 38 insertions, 1 deletions
diff --git a/common/Cargo.toml b/common/Cargo.toml
index 066e79c..9038bc4 100644
--- a/common/Cargo.toml
+++ b/common/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-serde = { version = "1.0.217", features = ["derive"] }
+serde = { version = "1.0.217", features = ["derive", "rc"] }
bincode = { version = "2.0.0-rc.3", features = ["derive"] }
rocket = { workspace = true, optional = true }
chrono = { version = "0.4.39", features = ["serde"] }
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;