Skip to content

Commit 427ed73

Browse files
authored
Merge pull request #4 from intelliDean/rev
restructure the logging
2 parents bab07d0 + a155523 commit 427ed73

23 files changed

Lines changed: 187 additions & 53 deletions

crates/api/src/handlers/add_bank.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use payego_core::services::bank_account_service::{
77
};
88
use payego_primitives::error::ApiErrorResponse;
99
use std::sync::Arc;
10-
use tracing::error;
10+
use tracing::warn;
1111
use validator::Validate;
1212

1313
#[utoipa::path(
@@ -34,7 +34,7 @@ pub async fn add_bank_account(
3434
Json(req): Json<BankRequest>,
3535
) -> Result<(StatusCode, Json<BankAccountResponse>), ApiError> {
3636
req.validate().map_err(|e| {
37-
error!("Validation error: {}", e);
37+
warn!("add_bank: validation error");
3838
ApiError::Validation(e)
3939
})?;
4040

crates/api/src/handlers/current_user.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ use std::sync::Arc;
1111
#[utoipa::path(
1212
get,
1313
path = "/api/user/current",
14+
tag = "User",
1415
summary = "Get current authenticated user details",
1516
description = "Retrieves profile information for the currently authenticated user based on the JWT bearer token. \
16-
Returns user data including ID, email, name, etc. \
17+
Returns user data including ID, email, name, phone, and account status. \
1718
Requires a valid authentication token.",
1819
operation_id = "getCurrentUser",
19-
tags = ["Authentication"],
2020
responses(
2121
(status = 200,description = "Successfully retrieved current user data",body = CurrentUserResponse,),
2222
(status = 401,description = "Unauthorized – missing, invalid, or expired token",body = ApiErrorResponse,),

crates/api/src/handlers/delete_bank.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ use uuid::Uuid;
1818
("bank_account_id" = Uuid, Path, description = "Bank account ID to delete")
1919
),
2020
responses(
21-
(status = 204, description = "Bank account deleted successfully"),
21+
(status = 200, description = "Bank account deleted successfully", body = DeleteResponse),
2222
(status = 401, description = "Unauthorized – missing or invalid token", body = ApiErrorResponse),
23-
(status = 404, description = "Bank account not found", body = ApiErrorResponse),
24-
(status = 409, description = "Bank account cannot be deleted", body = ApiErrorResponse),
23+
(status = 404, description = "Bank account not found or does not belong to user", body = ApiErrorResponse),
24+
(status = 409, description = "Conflict – bank account cannot be deleted (e.g., pending transactions)", body = ApiErrorResponse),
2525
(status = 500, description = "Internal server error", body = ApiErrorResponse),
2626
),
2727
security(("bearerAuth" = [])),

crates/api/src/handlers/get_transaction.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ use std::sync::Arc;
88
#[utoipa::path(
99
get,
1010
path = "/api/user/transactions",
11+
tag = "Transactions",
1112
summary = "Get list of user transactions",
1213
description = "Retrieves a paginated list of the authenticated user's transaction history. \
1314
Includes deposits, withdrawals, internal transfers, external transfers, \
1415
top-ups, payments, and other wallet activities. \
1516
Results are ordered by creation date (newest first). \
1617
Supports filtering and pagination via query parameters.",
1718
operation_id = "getUserTransactions",
18-
tags = ["Transactions"],
1919
2020
responses(
2121
(status = 200,description = "Successfully retrieved paginated list of transactions",body = TransactionsResponse),

crates/api/src/handlers/health.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use diesel::prelude::*;
33
use payego_primitives::models::app_state::AppState;
44
use payego_primitives::models::dtos::auth_dto::HealthStatus;
55
use std::sync::Arc;
6-
use tracing::log::error;
6+
use tracing::error;
77

88
#[utoipa::path(
99
get,

crates/api/src/handlers/internal_conversion.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use payego_core::services::conversion_service::{
44
};
55
use payego_primitives::error::ApiErrorResponse;
66
use std::sync::Arc;
7-
use tracing::error;
7+
use tracing::warn;
88
use validator::Validate;
99

1010
#[utoipa::path(
@@ -35,7 +35,7 @@ pub async fn convert_currency(
3535
Json(req): Json<ConvertRequest>,
3636
) -> Result<Json<ConvertResponse>, ApiError> {
3737
req.validate().map_err(|e| {
38-
error!("Validation error: {}", e);
38+
warn!("convert_currency: validation error");
3939
ApiError::Validation(e)
4040
})?;
4141

crates/api/src/handlers/login.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::sync::Arc;
1010
path = "/api/auth/login",
1111
tag = "Authentication",
1212
summary = "Authenticate user and obtain JWT token",
13-
description = "Authenticates a user using email and password\
13+
description = "Authenticates a user using email and password. \
1414
On success, returns a JWT access token, email and a refresh token that can be used \
1515
for subsequent authenticated requests via the `Authorization: Bearer <token>` header. \
1616
This is a public endpoint — no prior authentication is required.",

crates/api/src/handlers/refresh_token.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use payego_core::services::auth_service::token::{
44
};
55
use payego_primitives::error::ApiErrorResponse;
66
use std::sync::Arc;
7-
use tracing::log::error;
7+
use tracing::warn;
88
use validator::Validate;
99

1010
#[utoipa::path(
@@ -38,7 +38,7 @@ pub async fn refresh_token(
3838
Json(payload): Json<RefreshRequest>,
3939
) -> Result<Json<RefreshResponse>, ApiError> {
4040
payload.validate().map_err(|e| {
41-
error!("Validation error: {}", e);
41+
warn!("refresh_token: validation error");
4242
ApiError::Validation(e)
4343
})?;
4444

crates/api/src/handlers/register.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use payego_core::services::auth_service::register::{
77
};
88
use payego_primitives::error::ApiErrorResponse;
99
use std::sync::Arc;
10-
use tracing::log::error;
10+
use tracing::warn;
1111
use validator::Validate;
1212

1313
#[utoipa::path(
@@ -43,7 +43,7 @@ pub async fn register(
4343
let payload = payload.normalize();
4444

4545
payload.validate().map_err(|e| {
46-
error!("Validation error: {}", e);
46+
warn!("register: validation error");
4747
ApiError::Validation(e)
4848
})?;
4949

crates/api/src/handlers/resolve_account.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ use tracing::info;
1919
Requires valid Nigerian bank code (from Paystack supported banks list) and 10-digit account number. \
2020
The endpoint is rate-limited and depends on Paystack availability — cache results when possible for repeated lookups.",
2121
operation_id = "resolveAccountName",
22+
params(
23+
("account_number" = String, Query, description = "10-digit bank account number to verify"),
24+
("bank_code" = String, Query, description = "Bank code from Paystack supported banks list (e.g., '058' for GTBank)")
25+
),
2226
responses(
2327
( status = 200, description = "Account successfully resolved — returns account name and other verification details", body = ResolveAccountResponse),
2428
( status = 400, description = "Bad request — invalid bank code, account number format, or missing required parameters", body = ApiErrorResponse),

0 commit comments

Comments
 (0)