From 22348bfa35f009e62abe2f30863e0434079a1fe2 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 18 Sep 2024 22:49:38 -0400 Subject: Remove the HTML client, and expose a JSON API. This API structure fell out of a conversation with Kit. Described loosely: kit: ok kit: Here's what I'm picturing in a client kit: list channels, make-new-channel, zero to one active channels, post-to-active. kit: login/sign-up, logout owen: you will likely also want "am I logged in" here kit: sure, whoami --- src/index/app.rs | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 src/index/app.rs (limited to 'src/index/app.rs') diff --git a/src/index/app.rs b/src/index/app.rs deleted file mode 100644 index 4f234ee..0000000 --- a/src/index/app.rs +++ /dev/null @@ -1,36 +0,0 @@ -use sqlx::sqlite::SqlitePool; - -use crate::repo::{ - channel::{self, Channel, Provider as _}, - error::NotFound as _, -}; - -pub struct Index<'a> { - db: &'a SqlitePool, -} - -impl<'a> Index<'a> { - pub const fn new(db: &'a SqlitePool) -> Self { - Self { db } - } - - pub async fn channel(&self, channel: &channel::Id) -> Result { - let mut tx = self.db.begin().await?; - let channel = tx - .channels() - .by_id(channel) - .await - .not_found(|| Error::ChannelNotFound(channel.clone()))?; - tx.commit().await?; - - Ok(channel) - } -} - -#[derive(Debug, thiserror::Error)] -pub enum Error { - #[error("channel {0} not found")] - ChannelNotFound(channel::Id), - #[error(transparent)] - DatabaseError(#[from] sqlx::Error), -} -- cgit v1.2.3