From 0ce64a50b763d2b19f5ca254233370418f4b7658 Mon Sep 17 00:00:00 2001 From: metamuffin Date: Thu, 6 Feb 2025 16:52:46 +0100 Subject: add json capability to most useful endpoints --- common/src/api.rs | 36 ++++++++++++++++++++++++++++++++++++ common/src/lib.rs | 1 + 2 files changed, 37 insertions(+) create mode 100644 common/src/api.rs (limited to 'common/src') 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 +*/ + +use crate::{user::NodeUserData, Node}; +use serde::{Deserialize, Serialize}; +use std::sync::Arc; + +#[derive(Serialize, Deserialize)] +pub struct ApiNodeResponse { + pub parents: Vec<(Arc, NodeUserData)>, + pub children: Vec<(Arc, NodeUserData)>, + pub node: Arc, + pub userdata: NodeUserData, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiSearchResponse { + pub count: usize, + pub results: Vec<(Arc, NodeUserData)>, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiItemsResponse { + pub count: usize, + pub pages: usize, + pub items: Vec<(Arc, NodeUserData)>, +} + +#[derive(Serialize, Deserialize)] +pub struct ApiHomeResponse { + pub toplevel: Vec<(Arc, NodeUserData)>, + pub categories: Vec<(String, Vec<(Arc, 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 */ +pub mod api; pub mod config; pub mod helpers; pub mod r#impl; -- cgit v1.2.3-70-g09d2