From 4c73ae9ee6e322fd8cba8d4290a5a86d85651576 Mon Sep 17 00:00:00 2001 From: WriterV2 Date: Fri, 21 Nov 2025 15:27:21 +0100 Subject: Add admin endpoints to list stories and products --- src/handlers/admin.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/handlers/admin.rs') diff --git a/src/handlers/admin.rs b/src/handlers/admin.rs index 1cc3068..03c933b 100644 --- a/src/handlers/admin.rs +++ b/src/handlers/admin.rs @@ -11,6 +11,7 @@ use axum::{Extension, Json}; use rand::Rng; use subtle::ConstantTimeEq; +use crate::db::product::get_all_products; use crate::db::story::{format_filepath, Story}; use crate::db::ProductDatabaseHandler; use crate::error::AppError; @@ -140,3 +141,13 @@ pub async fn delete_story( } Ok(StatusCode::BAD_REQUEST.into_response()) } + +pub async fn get_stories(ctx: Extension) -> Result { + let stories = Story::get_all(&ctx.pool).await?; + Ok((StatusCode::OK, Json(stories)).into_response()) +} + +pub async fn get_products(ctx: Extension) -> Result { + let products = get_all_products(&ctx.pool).await?; + Ok((StatusCode::OK, Json(products)).into_response()) +} -- cgit v1.2.3