Skip to content

Commit

Permalink
clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ppamorim committed Jan 16, 2025
1 parent 7c3ce39 commit b7714a4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
24 changes: 14 additions & 10 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ mod helpers;
mod shared;
mod users;

use std::{cmp::max, sync::{Arc, LazyLock}};
use std::{
cmp::max,
sync::{Arc, LazyLock},
};

use actix_governor::{
governor::{clock::QuantaInstant, middleware::NoOpMiddleware},
Expand All @@ -15,7 +18,11 @@ use auth::{access_token, auth_login};
use nanoid::nanoid;
use rayon::ThreadPoolBuilder;
use shared::{
check_health, config::Config, database::{Database, InMemoryDatabase}, hash_worker::{HashWorker, Hasher}, middleware::master_key_middleware::bearer_validator
check_health,
config::Config,
database::{Database, InMemoryDatabase},
hash_worker::{HashWorker, Hasher},
middleware::master_key_middleware::bearer_validator,
};
use users::{
create_user, get_users,
Expand All @@ -26,9 +33,8 @@ use users::{
async fn main() -> std::io::Result<()> {
println!("Starting taille-auth...");
let config = Config::default().await;
let user_repository = UserRepositoryImpl::new(
InMemoryDatabase::new(&config).await.unwrap()
);
let user_repository =
UserRepositoryImpl::new(InMemoryDatabase::new(&config).await.unwrap());
let user_repository = Arc::new(user_repository);

let thread_pool = ThreadPoolBuilder::new()
Expand Down Expand Up @@ -102,10 +108,7 @@ fn apply_service_config<UR: UserRepository + 'static, H: Hasher + 'static>(
.route("", web::get().to(get_users::<UR>))
.route("", web::post().to(create_user::<UR, H>)),
)
.service(
web::scope("/health")
.route("", web::get().to(check_health))
)
.service(web::scope("/health").route("", web::get().to(check_health))),
);
}

Expand All @@ -114,7 +117,8 @@ fn num_threads() -> usize {
}

static CUSTOM_ALPHABET: LazyLock<Vec<char>> = LazyLock::new(|| {
nanoid::alphabet::SAFE.iter()
nanoid::alphabet::SAFE
.iter()
.filter(|&&c| c != '_' && c != '-')
.copied()
.collect()
Expand Down
8 changes: 3 additions & 5 deletions src/shared/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ pub struct Config {

impl Config {
pub async fn default() -> Self {
let host =
env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string());
let port =
env::var("PORT").unwrap_or_else(|_| "3000".to_string());
let host = env::var("HOST").unwrap_or_else(|_| "0.0.0.0".to_string());
let port = env::var("PORT").unwrap_or_else(|_| "3000".to_string());
let master_key =
env::var("MASTER_KEY").unwrap_or_else(|_| "DEV_MASTER_KEY".to_string());
let jwt_secret =
env::var("JWT_SECRET").unwrap_or_else(|_| "DEV_JWT_SECRET".to_string());
Self {
address: format!("{}:{}", host, port),
master_key,
jwt_secret
jwt_secret,
}
}
}
2 changes: 1 addition & 1 deletion src/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ pub mod rto;

pub async fn check_health() -> impl Responder {
HttpResponse::Ok().finish()
}
}

0 comments on commit b7714a4

Please sign in to comment.