From 51a1b85429d292a7f09a2b67a669ab3309a19f34 Mon Sep 17 00:00:00 2001 From: Rogier Reerink Date: Mon, 12 Oct 2026 18:19:15 +0200 Subject: [PATCH] Reordered state extractors. --- server/src/routes/account_members.rs | 17 +++++++++-------- server/src/routes/accounts.rs | 6 +++--- server/src/routes/scheduled_transactions.rs | 8 ++++---- server/src/routes/transactions.rs | 6 +++--- server/src/routes/user_app_secrets.rs | 8 ++++---- server/src/routes/user_apps.rs | 8 ++++---- server/src/routes/users.rs | 6 +++--- 7 files changed, 30 insertions(+), 29 deletions(-) diff --git a/server/src/routes/account_members.rs b/server/src/routes/account_members.rs index 83742da..fd7b447 100644 --- a/server/src/routes/account_members.rs +++ b/server/src/routes/account_members.rs @@ -32,9 +32,9 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_account_members( Auth(auth): Auth, - State(pool): State, Path(account_id): Path, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { let user_id = auth.user_id(); @@ -63,13 +63,14 @@ async fn list_account_members( #[tracing::instrument(skip(pool))] async fn get_account_member( Auth(auth): Auth, - State(pool): State, Path((account_id, member_id)): Path<(Uuid, Uuid)>, + State(pool): State, ) -> Result, AppError> { - let member = - repository::account_members::get_by_id(&pool, auth.user_id(), account_id, member_id) - .await? - .ok_or(AppError::NotFound)?; + let user_id = auth.user_id(); + + let member = repository::account_members::get_by_id(&pool, user_id, account_id, member_id) + .await? + .ok_or(AppError::NotFound)?; let users = repository::users::get_by_id(&pool, member.user_id) .await? .map(|user| HashMap::from([(user.id, user)])) @@ -82,8 +83,8 @@ async fn get_account_member( #[tracing::instrument(skip(pool, member))] async fn upsert_account_member( Auth(auth): Auth, - State(pool): State, Path((account_id, member_id)): Path<(Uuid, Uuid)>, + State(pool): State, Json(member): Json, ) -> Result<(StatusCode, Json), AppError> { let user_id = auth.user_id(); @@ -115,8 +116,8 @@ async fn upsert_account_member( #[tracing::instrument(skip(pool))] async fn delete_account_member( Auth(auth): Auth, - State(pool): State, Path((account_id, member_id)): Path<(Uuid, Uuid)>, + State(pool): State, ) -> Result { let user_id = auth.user_id(); diff --git a/server/src/routes/accounts.rs b/server/src/routes/accounts.rs index 35bc5d6..0277474 100644 --- a/server/src/routes/accounts.rs +++ b/server/src/routes/accounts.rs @@ -31,8 +31,8 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_accounts( Auth(auth): Auth, - State(pool): State, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { let query = repository::accounts::Query { name: query.name, @@ -53,8 +53,8 @@ async fn list_accounts( #[tracing::instrument(skip(pool))] async fn get_account( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, ) -> Result, AppError> { let account = repository::accounts::get_by_id(&pool, auth.user_id(), id) .await? @@ -67,8 +67,8 @@ async fn get_account( #[tracing::instrument(skip(pool, account))] async fn upsert_account( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, Json(account): Json, ) -> Result<(StatusCode, Json), AppError> { let user_id = auth.user_id(); diff --git a/server/src/routes/scheduled_transactions.rs b/server/src/routes/scheduled_transactions.rs index 00f3417..d4f7b36 100644 --- a/server/src/routes/scheduled_transactions.rs +++ b/server/src/routes/scheduled_transactions.rs @@ -35,8 +35,8 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_scheduled_transactions( Auth(auth): Auth, - State(pool): State, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { let user_id = auth.user_id(); @@ -60,8 +60,8 @@ async fn list_scheduled_transactions( #[tracing::instrument(skip(pool))] async fn get_scheduled_transaction( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, ) -> Result, AppError> { let user_id = auth.user_id(); @@ -83,8 +83,8 @@ async fn get_scheduled_transaction( #[tracing::instrument(skip(pool, transaction))] async fn upsert_scheduled_transaction( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, Json(transaction): Json, ) -> Result<(StatusCode, Json), AppError> { let user_id = auth.user_id(); @@ -117,8 +117,8 @@ async fn upsert_scheduled_transaction( #[tracing::instrument(skip(pool))] async fn delete_scheduled_transaction( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, ) -> Result { repository::recurring_transactions::delete_by_id(&pool, auth.user_id(), id) .await? diff --git a/server/src/routes/transactions.rs b/server/src/routes/transactions.rs index e329070..13276ef 100644 --- a/server/src/routes/transactions.rs +++ b/server/src/routes/transactions.rs @@ -32,8 +32,8 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_transactions( Auth(auth): Auth, - State(pool): State, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { let user_id = auth.user_id(); @@ -57,8 +57,8 @@ async fn list_transactions( #[tracing::instrument(skip(pool))] async fn get_transaction( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, ) -> Result, AppError> { let user_id = auth.user_id(); @@ -79,8 +79,8 @@ async fn get_transaction( #[tracing::instrument(skip(pool, transaction))] async fn upsert_transaction( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, Json(transaction): Json, ) -> Result<(StatusCode, Json), AppError> { let user_id = auth.user_id(); diff --git a/server/src/routes/user_app_secrets.rs b/server/src/routes/user_app_secrets.rs index 106834e..1f96f84 100644 --- a/server/src/routes/user_app_secrets.rs +++ b/server/src/routes/user_app_secrets.rs @@ -37,9 +37,9 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_user_app_secrets( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id)): Path<(Uuid, Uuid)>, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { if auth.user_id() != user_id { return Err(AppError::NotFound); @@ -67,8 +67,8 @@ async fn list_user_app_secrets( #[tracing::instrument(skip(pool))] async fn get_user_app_secret( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id, secret_id)): Path<(Uuid, Uuid, Uuid)>, + State(pool): State, ) -> Result, AppError> { if auth.user_id() != user_id { return Err(AppError::NotFound); @@ -85,8 +85,8 @@ async fn get_user_app_secret( #[tracing::instrument(skip(pool, request))] async fn upsert_user_app_secret( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id, secret_id)): Path<(Uuid, Uuid, Uuid)>, + State(pool): State, Json(request): Json, ) -> Result<(StatusCode, Json), AppError> { if auth.user_id() != user_id { @@ -120,8 +120,8 @@ async fn upsert_user_app_secret( #[tracing::instrument(skip(pool))] async fn delete_user_app_secret( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id, secret_id)): Path<(Uuid, Uuid, Uuid)>, + State(pool): State, ) -> Result { if auth.user_id() != user_id { return Err(AppError::NotFound); diff --git a/server/src/routes/user_apps.rs b/server/src/routes/user_apps.rs index 5e356f7..5f66c4f 100644 --- a/server/src/routes/user_apps.rs +++ b/server/src/routes/user_apps.rs @@ -30,9 +30,9 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_user_apps( Auth(auth): Auth, - State(pool): State, Path(user_id): Path, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { if auth.user_id() != user_id { return Err(AppError::NotFound); @@ -56,8 +56,8 @@ async fn list_user_apps( #[tracing::instrument(skip(pool))] async fn get_user_app( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id)): Path<(Uuid, Uuid)>, + State(pool): State, ) -> Result, AppError> { if auth.user_id() != user_id { return Err(AppError::NotFound); @@ -74,8 +74,8 @@ async fn get_user_app( #[tracing::instrument(skip(pool, request))] async fn upsert_user_app( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id)): Path<(Uuid, Uuid)>, + State(pool): State, Json(request): Json, ) -> Result<(StatusCode, Json), AppError> { if auth.user_id() != user_id { @@ -100,8 +100,8 @@ async fn upsert_user_app( #[tracing::instrument(skip(pool))] async fn delete_user_app( Auth(auth): Auth, - State(pool): State, Path((user_id, app_id)): Path<(Uuid, Uuid)>, + State(pool): State, ) -> Result { if auth.user_id() != user_id { return Err(AppError::NotFound); diff --git a/server/src/routes/users.rs b/server/src/routes/users.rs index cee0f38..e63802c 100644 --- a/server/src/routes/users.rs +++ b/server/src/routes/users.rs @@ -30,8 +30,8 @@ pub struct QueryParams { #[tracing::instrument(skip(pool))] async fn list_users( Auth(auth): Auth, - State(pool): State, Query(query): Query, + State(pool): State, ) -> Result>, AppError> { let query = repository::users::Query { limit: Some(query.limit.unwrap_or(20)), @@ -51,8 +51,8 @@ async fn list_users( #[tracing::instrument(skip(pool))] async fn get_user( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, ) -> Result, AppError> { let user = repository::users::get_by_id(&pool, id) .await? @@ -65,8 +65,8 @@ async fn get_user( #[tracing::instrument(skip(pool, user))] async fn upsert_user( Auth(auth): Auth, - State(pool): State, Path(id): Path, + State(pool): State, Json(user): Json, ) -> Result<(StatusCode, Json), AppError> { let user = user.into_domain(id)?;