diff --git a/crates/api/src/config/mod.rs b/crates/api/src/config/mod.rs index de249f2..341a6d3 100644 --- a/crates/api/src/config/mod.rs +++ b/crates/api/src/config/mod.rs @@ -1,3 +1,3 @@ -pub(crate) use local_tracing::*; - mod local_tracing; + +pub(crate) use local_tracing::*; diff --git a/crates/api/src/handlers/admin/mod.rs b/crates/api/src/handlers/admin/mod.rs index 04cc94a..a25db5b 100644 --- a/crates/api/src/handlers/admin/mod.rs +++ b/crates/api/src/handlers/admin/mod.rs @@ -1,3 +1,3 @@ -pub(crate) use conn::*; - mod conn; + +pub(crate) use conn::*; diff --git a/crates/api/src/handlers/auth/mod.rs b/crates/api/src/handlers/auth/mod.rs index a94ea59..d2edf0f 100644 --- a/crates/api/src/handlers/auth/mod.rs +++ b/crates/api/src/handlers/auth/mod.rs @@ -1,7 +1,7 @@ -pub(crate) use discord::*; -pub(crate) use user::*; -pub(crate) use verify::*; - mod discord; mod user; mod verify; + +pub(crate) use discord::*; +pub(crate) use user::*; +pub(crate) use verify::*; diff --git a/crates/api/src/handlers/championships/stream.rs b/crates/api/src/handlers/championships/stream.rs index 0ffb4a7..7a53078 100644 --- a/crates/api/src/handlers/championships/stream.rs +++ b/crates/api/src/handlers/championships/stream.rs @@ -1,5 +1,7 @@ -use std::pin::Pin; -use std::task::{Context, Poll}; +use std::{ + pin::Pin, + task::{Context, Poll}, +}; use garde::Validate; use ntex::{ diff --git a/crates/api/src/handlers/mod.rs b/crates/api/src/handlers/mod.rs index 664621a..eb2efb0 100644 --- a/crates/api/src/handlers/mod.rs +++ b/crates/api/src/handlers/mod.rs @@ -1,10 +1,10 @@ -use ntex::web::HttpResponse; - pub(crate) mod admin; pub(crate) mod auth; pub(crate) mod championships; pub(crate) mod user; +use ntex::web::HttpResponse; + pub(crate) async fn system_health_check() -> HttpResponse { HttpResponse::Ok().finish() } diff --git a/crates/api/src/handlers/user/mod.rs b/crates/api/src/handlers/user/mod.rs index 1dfd0b3..9a78f4c 100644 --- a/crates/api/src/handlers/user/mod.rs +++ b/crates/api/src/handlers/user/mod.rs @@ -1,3 +1,5 @@ +pub(crate) mod admin; + use garde::Validate; use ntex::web::{ types::{Json, State}, @@ -11,8 +13,6 @@ use structs::{UserProfileData, UserUpdateData}; use crate::states::AppState; -pub(crate) mod admin; - #[inline] pub(crate) async fn get(req: HttpRequest, state: State) -> AppResult { let user = req.user()?; diff --git a/crates/api/src/middlewares/mod.rs b/crates/api/src/middlewares/mod.rs index 4c988b8..b5e5f3a 100644 --- a/crates/api/src/middlewares/mod.rs +++ b/crates/api/src/middlewares/mod.rs @@ -1,7 +1,7 @@ -pub(crate) use admin::*; -pub(crate) use authenticated::*; -pub(crate) use login::*; - mod admin; mod authenticated; mod login; + +pub(crate) use admin::*; +pub(crate) use authenticated::*; +pub(crate) use login::*; diff --git a/crates/api/src/routes/mod.rs b/crates/api/src/routes/mod.rs index d369d2c..133da09 100644 --- a/crates/api/src/routes/mod.rs +++ b/crates/api/src/routes/mod.rs @@ -1,5 +1,5 @@ -pub(crate) use admin::*; -pub(crate) use api::*; - mod admin; mod api; + +pub(crate) use admin::*; +pub(crate) use api::*; diff --git a/crates/api/src/states/mod.rs b/crates/api/src/states/mod.rs index 303c2ae..49f83f0 100644 --- a/crates/api/src/states/mod.rs +++ b/crates/api/src/states/mod.rs @@ -1,3 +1,3 @@ -pub(crate) use app::*; - mod app; + +pub(crate) use app::*; diff --git a/crates/db/src/cache/mod.rs b/crates/db/src/cache/mod.rs index 61b4937..5e43101 100644 --- a/crates/db/src/cache/mod.rs +++ b/crates/db/src/cache/mod.rs @@ -1,13 +1,13 @@ +mod championship; +mod driver; +mod user; + use std::sync::Arc; use driver::DriverCache; use self::{championship::ChampionshipCache, user::UserCache}; -mod championship; -mod driver; -mod user; - const CACHE_CAPACITY: usize = 2_000; /// Caching layer for users, championships, and tokens. diff --git a/crates/db/src/db.rs b/crates/db/src/db.rs index ba1a0d6..a94ace0 100644 --- a/crates/db/src/db.rs +++ b/crates/db/src/db.rs @@ -1,3 +1,5 @@ +mod cache; + use std::{ops::DerefMut, str::FromStr}; use cache::ServiceCache; @@ -11,8 +13,6 @@ use tracing::info; pub use cache::EntityCache; -mod cache; - embed_migrations!("migrations"); /// Encapsulates Postgres database connections. diff --git a/crates/entities/src/entities.rs b/crates/entities/src/entities.rs index 7e9e232..e67bda3 100644 --- a/crates/entities/src/entities.rs +++ b/crates/entities/src/entities.rs @@ -1,3 +1,9 @@ +mod championship; +mod driver; +mod race; +mod result; +mod user; + pub use championship::*; pub use driver::*; #[allow(unused)] @@ -5,9 +11,3 @@ pub use race::*; #[allow(unused)] pub use result::*; pub use user::*; - -mod championship; -mod driver; -mod race; -mod result; -mod user; diff --git a/crates/error/src/error.rs b/crates/error/src/error.rs index aa4fcb7..afcf37f 100644 --- a/crates/error/src/error.rs +++ b/crates/error/src/error.rs @@ -1,3 +1,11 @@ +mod championship; +mod common; +mod driver; +mod f1; +mod firewall; +mod token; +mod user; + use deadpool_postgres::{tokio_postgres::Error as PgError, PoolError}; use ntex::{ http::{ @@ -17,14 +25,6 @@ pub use firewall::*; pub use token::*; pub use user::*; -mod championship; -mod common; -mod driver; -mod f1; -mod firewall; -mod token; -mod user; - pub type AppResult = Result; // TODO: Handle 3rd party errors in a better way diff --git a/crates/id-generator/src/id_generator.rs b/crates/id-generator/src/id_generator.rs index aec9378..ffeb151 100644 --- a/crates/id-generator/src/id_generator.rs +++ b/crates/id-generator/src/id_generator.rs @@ -1,12 +1,13 @@ #![feature(portable_simd)] -use ahash::AHashSet; -use parking_lot::Mutex; -use ring::rand::{SecureRandom, SystemRandom}; use std::{ ops::Range, simd::{i32x16, num::SimdInt, Simd}, }; +use ahash::AHashSet; +use parking_lot::Mutex; +use ring::rand::{SecureRandom, SystemRandom}; + const IDS_POOL_SIZE: usize = 1024; /// A structure to manage a set of bits efficiently. diff --git a/crates/intelli-core/src/repositories/mod.rs b/crates/intelli-core/src/repositories/mod.rs index ad5731e..ccacd4a 100644 --- a/crates/intelli-core/src/repositories/mod.rs +++ b/crates/intelli-core/src/repositories/mod.rs @@ -1,11 +1,11 @@ -pub use championship::*; -pub use discord::*; -pub use driver::*; -pub use server::*; -pub use user::*; - mod championship; mod discord; mod driver; mod server; mod user; + +pub use championship::*; +pub use discord::*; +pub use driver::*; +pub use server::*; +pub use user::*; diff --git a/crates/intelli-core/src/services/mod.rs b/crates/intelli-core/src/services/mod.rs index dbea376..96fd4a2 100644 --- a/crates/intelli-core/src/services/mod.rs +++ b/crates/intelli-core/src/services/mod.rs @@ -1,9 +1,9 @@ -pub use championship::*; -pub use driver::*; -pub use email::*; -pub use user::*; - mod championship; mod driver; mod email; mod user; + +pub use championship::*; +pub use driver::*; +pub use email::*; +pub use user::*; diff --git a/crates/structs/src/structs.rs b/crates/structs/src/structs.rs index 71558f1..10a80a9 100644 --- a/crates/structs/src/structs.rs +++ b/crates/structs/src/structs.rs @@ -1,11 +1,11 @@ -pub use auth::*; -pub use championship::*; -pub use server::*; -pub use templates::*; -pub use user::*; - mod auth; mod championship; mod server; mod templates; mod user; + +pub use auth::*; +pub use championship::*; +pub use server::*; +pub use templates::*; +pub use user::*; diff --git a/crates/telemetry/src/f1.rs b/crates/telemetry/src/f1.rs index faeed93..44915f9 100644 --- a/crates/telemetry/src/f1.rs +++ b/crates/telemetry/src/f1.rs @@ -2,7 +2,7 @@ // -------------- ORIGINAL GAME ---------------- // --------------------------------------------- -use core::str; +use std::str; use error::{AppError, ChampionshipError}; diff --git a/crates/telemetry/src/firewall.rs b/crates/telemetry/src/firewall.rs index 52a5289..861e616 100644 --- a/crates/telemetry/src/firewall.rs +++ b/crates/telemetry/src/firewall.rs @@ -1,7 +1,8 @@ +use std::{net::IpAddr, process::Command as StdCommand, str}; + use ahash::AHashMap; use error::{AppResult, FirewallError}; use regex::Regex; -use std::{net::IpAddr, process::Command as StdCommand, str}; use tokio::process::Command; use tokio::sync::RwLock; use tracing::{error, warn}; diff --git a/crates/telemetry/src/manager.rs b/crates/telemetry/src/manager.rs index c4d3923..cb2d83a 100644 --- a/crates/telemetry/src/manager.rs +++ b/crates/telemetry/src/manager.rs @@ -1,3 +1,5 @@ +use std::{ops::Deref, sync::Arc, time::Duration}; + use ahash::{AHashMap, AHashSet}; use ntex::{ time::interval, @@ -5,7 +7,6 @@ use ntex::{ }; use parking_lot::{Mutex, RwLock}; use prost::Message; -use std::{ops::Deref, sync::Arc, time::Duration}; use tokio::sync::{ broadcast::{Receiver, Sender}, oneshot, diff --git a/crates/token_manager/src/persistence.rs b/crates/token_manager/src/persistence.rs index 3d154e1..e0750c8 100644 --- a/crates/token_manager/src/persistence.rs +++ b/crates/token_manager/src/persistence.rs @@ -1,8 +1,12 @@ +use std::{ + collections::VecDeque, + fs::{File, OpenOptions}, + io::{Read, Write}, + mem::size_of, +}; + use dashmap::DashMap; -use std::collections::VecDeque; -use std::fs::{File, OpenOptions}; -use std::io::{Read, Write}; -use std::mem::size_of; + use utils::current_timestamp_s; use crate::token::{Header, Token, TokenEntry}; diff --git a/crates/token_manager/src/token.rs b/crates/token_manager/src/token.rs index 46baf83..411ad8d 100644 --- a/crates/token_manager/src/token.rs +++ b/crates/token_manager/src/token.rs @@ -1,9 +1,10 @@ use std::slice; use base64_simd::{Out, URL_SAFE_NO_PAD}; -use error::{AppResult, TokenError}; use ring::rand::{SecureRandom, SystemRandom}; +use error::{AppResult, TokenError}; + #[repr(C)] #[derive(Clone, Copy, PartialEq, Eq, Hash)] pub struct Token([u8; 16]); diff --git a/crates/token_manager/src/token_manager.rs b/crates/token_manager/src/token_manager.rs index 26ef4f2..76aec19 100644 --- a/crates/token_manager/src/token_manager.rs +++ b/crates/token_manager/src/token_manager.rs @@ -1,16 +1,17 @@ +mod persistence; +mod token; + use std::{collections::VecDeque, time::Duration}; use dashmap::DashMap; use error::{AppResult, TokenError}; use token::TokenEntry; -mod persistence; -mod token; - -pub use token::{Token, TokenIntent}; use tokio::{task, time::sleep}; use utils::current_timestamp_s; +pub use token::{Token, TokenIntent}; + const MAX_TOKENS_PER_USER: usize = 10; const PURGE_INTERVAL: Duration = Duration::from_secs(900);