summaryrefslogtreecommitdiff
path: root/src/handlers/admin.rs
diff options
context:
space:
mode:
authorWriterV2 <primary-v2@protonmail.com>2025-11-21 15:27:21 +0100
committerWriterV2 <primary-v2@protonmail.com>2025-11-21 15:27:21 +0100
commit4c73ae9ee6e322fd8cba8d4290a5a86d85651576 (patch)
tree574f47015d87e1d61ad33f6fd85d106a18f2e1ba /src/handlers/admin.rs
parent66d7a13414e2b185df5155a83bbdb842d3618c27 (diff)
Add admin endpoints to list stories and products
Diffstat (limited to 'src/handlers/admin.rs')
-rw-r--r--src/handlers/admin.rs11
1 files changed, 11 insertions, 0 deletions
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<ApiContext>) -> Result<impl IntoResponse, AppError> {
+ let stories = Story::get_all(&ctx.pool).await?;
+ Ok((StatusCode::OK, Json(stories)).into_response())
+}
+
+pub async fn get_products(ctx: Extension<ApiContext>) -> Result<impl IntoResponse, AppError> {
+ let products = get_all_products(&ctx.pool).await?;
+ Ok((StatusCode::OK, Json(products)).into_response())
+}