mirror of
https://github.com/atuinsh/atuin.git
synced 2024-11-23 00:34:20 +01:00
feat(server): add me endpoint (#1954)
This commit is contained in:
parent
a0231a7095
commit
19f70cdc91
@ -115,3 +115,8 @@ pub struct DeleteHistoryRequest {
|
|||||||
pub struct MessageResponse {
|
pub struct MessageResponse {
|
||||||
pub message: String,
|
pub message: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
pub struct MeResponse {
|
||||||
|
pub username: String,
|
||||||
|
}
|
||||||
|
16
atuin-server/src/handlers/v0/me.rs
Normal file
16
atuin-server/src/handlers/v0/me.rs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
use axum::Json;
|
||||||
|
use tracing::instrument;
|
||||||
|
|
||||||
|
use crate::handlers::ErrorResponseStatus;
|
||||||
|
use crate::router::UserAuth;
|
||||||
|
|
||||||
|
use atuin_common::api::*;
|
||||||
|
|
||||||
|
#[instrument(skip_all, fields(user.id = user.id))]
|
||||||
|
pub async fn get(
|
||||||
|
UserAuth(user): UserAuth,
|
||||||
|
) -> Result<Json<MeResponse>, ErrorResponseStatus<'static>> {
|
||||||
|
Ok(Json(MeResponse {
|
||||||
|
username: user.username,
|
||||||
|
}))
|
||||||
|
}
|
@ -1,2 +1,3 @@
|
|||||||
|
pub(crate) mod me;
|
||||||
pub(crate) mod record;
|
pub(crate) mod record;
|
||||||
pub(crate) mod store;
|
pub(crate) mod store;
|
||||||
|
@ -125,6 +125,7 @@ pub fn router<DB: Database>(database: DB, settings: Settings<DB::Settings>) -> R
|
|||||||
.route("/record", post(handlers::record::post::<DB>))
|
.route("/record", post(handlers::record::post::<DB>))
|
||||||
.route("/record", get(handlers::record::index::<DB>))
|
.route("/record", get(handlers::record::index::<DB>))
|
||||||
.route("/record/next", get(handlers::record::next))
|
.route("/record/next", get(handlers::record::next))
|
||||||
|
.route("/api/v0/me", get(handlers::v0::me::get))
|
||||||
.route("/api/v0/record", post(handlers::v0::record::post))
|
.route("/api/v0/record", post(handlers::v0::record::post))
|
||||||
.route("/api/v0/record", get(handlers::v0::record::index))
|
.route("/api/v0/record", get(handlers::v0::record::index))
|
||||||
.route("/api/v0/record/next", get(handlers::v0::record::next))
|
.route("/api/v0/record/next", get(handlers::v0::record::next))
|
||||||
|
@ -23,8 +23,6 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
|
|||||||
|
|
||||||
let status = client.status().await?;
|
let status = client.status().await?;
|
||||||
let last_sync = Settings::last_sync()?;
|
let last_sync = Settings::last_sync()?;
|
||||||
let local_count = db.history_count(false).await?;
|
|
||||||
let deleted_count = db.history_count(true).await? - local_count;
|
|
||||||
|
|
||||||
println!("Atuin v{VERSION} - Build rev {SHA}\n");
|
println!("Atuin v{VERSION} - Build rev {SHA}\n");
|
||||||
|
|
||||||
@ -36,6 +34,9 @@ pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if !settings.sync.records {
|
if !settings.sync.records {
|
||||||
|
let local_count = db.history_count(false).await?;
|
||||||
|
let deleted_count = db.history_count(true).await? - local_count;
|
||||||
|
|
||||||
println!("History count: {local_count}");
|
println!("History count: {local_count}");
|
||||||
println!("Deleted history count: {deleted_count}\n");
|
println!("Deleted history count: {deleted_count}\n");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user