diff options
Diffstat (limited to 'atuin-server/src/handlers/v0')
-rw-r--r-- | atuin-server/src/handlers/v0/mod.rs | 1 | ||||
-rw-r--r-- | atuin-server/src/handlers/v0/store.rs | 37 |
2 files changed, 38 insertions, 0 deletions
diff --git a/atuin-server/src/handlers/v0/mod.rs b/atuin-server/src/handlers/v0/mod.rs index 78fb47b8a..2d6745cff 100644 --- a/atuin-server/src/handlers/v0/mod.rs +++ b/atuin-server/src/handlers/v0/mod.rs @@ -1 +1,2 @@ pub(crate) mod record; +pub(crate) mod store; diff --git a/atuin-server/src/handlers/v0/store.rs b/atuin-server/src/handlers/v0/store.rs new file mode 100644 index 000000000..941f24872 --- /dev/null +++ b/atuin-server/src/handlers/v0/store.rs @@ -0,0 +1,37 @@ +use axum::{extract::Query, extract::State, http::StatusCode}; +use metrics::counter; +use serde::Deserialize; +use tracing::{error, instrument}; + +use crate::{ + handlers::{ErrorResponse, ErrorResponseStatus, RespExt}, + router::{AppState, UserAuth}, +}; +use atuin_server_database::Database; + +#[derive(Deserialize)] +pub struct DeleteParams {} + +#[instrument(skip_all, fields(user.id = user.id))] +pub async fn delete<DB: Database>( + _params: Query<DeleteParams>, + UserAuth(user): UserAuth, + state: State<AppState<DB>>, +) -> Result<(), ErrorResponseStatus<'static>> { + let State(AppState { + database, + settings: _, + }) = state; + + if let Err(e) = database.delete_store(&user).await { + counter!("atuin_store_delete_failed", 1); + error!("failed to delete store {e:?}"); + + return Err(ErrorResponse::reply("failed to delete store") + .with_status(StatusCode::INTERNAL_SERVER_ERROR)); + } + + counter!("atuin_store_deleted", 1); + + Ok(()) +} |