- chore: ran cargo fix on the codebase

This commit is contained in:
2025-03-07 21:03:15 -05:00
parent 3b789d0fd4
commit b6f2d3f456
59 changed files with 1324 additions and 523 deletions

View File

@@ -1,6 +1,9 @@
fn main() -> Result<(), Box<dyn std::error::Error>> {
tonic_build::configure()
.compile_well_known_types(true)
.compile_protos(&["../proto/common.proto", "../proto/auth.proto"], &["../proto"])?;
.compile_protos(
&["../proto/common.proto", "../proto/auth.proto"],
&["../proto"],
)?;
Ok(())
}

View File

@@ -1,15 +1,12 @@
use axum::extract::{ConnectInfo, State};
use axum::http::Method;
use axum::{routing::post, Json, Router};
use serde::{Deserialize, Serialize};
use std::env;
use std::net::SocketAddr;
use std::sync::Arc;
use axum::http::Method;
use tonic::transport::Channel;
use tower_http::cors::{Any, CorsLayer};
use tower_http::trace::TraceLayer;
use tower::ServiceBuilder;
use auth::auth_service_client::AuthServiceClient;
use auth::{LoginRequest, RegisterRequest};
@@ -60,7 +57,7 @@ async fn login_handler(
let request = tonic::Request::new(LoginRequest {
username: payload.username.clone(),
password: payload.password.clone(),
ip_address
ip_address,
});
let mut client = grpc_client.lock().await; // Lock the mutex to get mutable access
@@ -99,11 +96,10 @@ async fn register_handler(
Err(e) => {
error!("gRPC Login call failed: {}", e);
Err(axum::http::StatusCode::INTERNAL_SERVER_ERROR)
},
}
}
}
pub async fn serve_rest_api(
grpc_client: Arc<Mutex<AuthServiceClient<Channel>>>,
) -> Result<(), Box<dyn std::error::Error + Send>> {
@@ -123,9 +119,12 @@ pub async fn serve_rest_api(
let listener = tokio::net::TcpListener::bind(format!("{}:{}", addr, port))
.await
.unwrap();
axum::serve(listener, app.into_make_service_with_connect_info::<SocketAddr>())
.await
.unwrap();
axum::serve(
listener,
app.into_make_service_with_connect_info::<SocketAddr>(),
)
.await
.unwrap();
Ok(())
}

View File

@@ -5,7 +5,6 @@ use std::env;
use std::str::FromStr;
use std::sync::Arc;
use tokio::sync::Mutex;
use tokio::{select, signal};
use tracing::{info, Level};
use utils::consul_registration;
use utils::service_discovery::get_service_address;