diff options
| author | Santo Cariotti <santo@dcariotti.me> | 2022-10-17 20:08:09 +0000 |
|---|---|---|
| committer | Santo Cariotti <santo@dcariotti.me> | 2022-10-17 20:08:09 +0000 |
| commit | 74976dab57887a4d7e29b426cdf7422722fa58ee (patch) | |
| tree | 5f1bbed3dbcf3ba520866cb4eb060aaf5a771915 | |
| parent | 611293122213f83e82d851cd8dc83fd1e4f79dcd (diff) | |
Refactoring of mods
| -rw-r--r-- | src/auth/mod.rs | 2 | ||||
| -rw-r--r-- | src/auth/models.rs (renamed from src/models/auth.rs) | 0 | ||||
| -rw-r--r-- | src/auth/routes.rs (renamed from src/routes/auth.rs) | 6 | ||||
| -rw-r--r-- | src/likes/mod.rs | 1 | ||||
| -rw-r--r-- | src/likes/models.rs (renamed from src/models/likes.rs) | 0 | ||||
| -rw-r--r-- | src/main.rs | 14 | ||||
| -rw-r--r-- | src/model/mod.rs | 2 | ||||
| -rw-r--r-- | src/model/models.rs (renamed from src/models/model.rs) | 0 | ||||
| -rw-r--r-- | src/model/routes.rs (renamed from src/routes/model.rs) | 10 | ||||
| -rw-r--r-- | src/models/mod.rs | 5 | ||||
| -rw-r--r-- | src/pagination.rs | 4 | ||||
| -rw-r--r-- | src/routes.rs (renamed from src/routes/mod.rs) | 5 | ||||
| -rw-r--r-- | src/user/mod.rs | 2 | ||||
| -rw-r--r-- | src/user/models.rs (renamed from src/models/user.rs) | 2 | ||||
| -rw-r--r-- | src/user/routes.rs (renamed from src/routes/user.rs) | 6 | ||||
| -rw-r--r-- | src/warning/mod.rs | 2 | ||||
| -rw-r--r-- | src/warning/models.rs (renamed from src/models/warning.rs) | 0 | ||||
| -rw-r--r-- | src/warning/routes.rs (renamed from src/routes/warning.rs) | 10 |
18 files changed, 34 insertions, 37 deletions
diff --git a/src/auth/mod.rs b/src/auth/mod.rs new file mode 100644 index 0000000..a0e1883 --- /dev/null +++ b/src/auth/mod.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod routes; diff --git a/src/models/auth.rs b/src/auth/models.rs index 8a673dd..8a673dd 100644 --- a/src/models/auth.rs +++ b/src/auth/models.rs diff --git a/src/routes/auth.rs b/src/auth/routes.rs index 0c459f5..65a5cb5 100644 --- a/src/routes/auth.rs +++ b/src/auth/routes.rs @@ -1,9 +1,7 @@ use crate::{ errors::AppError, - models::{ - auth::{AuthBody, Claims, LoginCredentials, SignUpForm}, - user::User, - }, + auth::models::{AuthBody, Claims, LoginCredentials, SignUpForm}, + user::models::User, routes::JsonCreate, }; use axum::{routing::post, Json, Router}; diff --git a/src/likes/mod.rs b/src/likes/mod.rs new file mode 100644 index 0000000..c446ac8 --- /dev/null +++ b/src/likes/mod.rs @@ -0,0 +1 @@ +pub mod models; diff --git a/src/models/likes.rs b/src/likes/models.rs index 56001d9..56001d9 100644 --- a/src/models/likes.rs +++ b/src/likes/models.rs diff --git a/src/main.rs b/src/main.rs index 19003f3..369b555 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,16 @@ +mod auth; mod config; mod db; mod errors; mod files; mod json; +mod likes; mod logger; -mod models; +mod model; mod pagination; mod routes; +mod user; +mod warning; use crate::config::{CONFIG, SENTRY}; use axum::{ @@ -57,10 +61,10 @@ async fn create_app() -> Router { let _ = db::setup().await; let api_routes = Router::new() - .nest("/users", routes::user::create_route()) - .nest("/auth", routes::auth::create_route()) - .nest("/models", routes::model::create_route()) - .nest("/warnings", routes::warning::create_route()); + .nest("/users", user::routes::create_route()) + .nest("/auth", auth::routes::create_route()) + .nest("/models", model::routes::create_route()) + .nest("/warnings", warning::routes::create_route()); Router::new() .route( diff --git a/src/model/mod.rs b/src/model/mod.rs new file mode 100644 index 0000000..a0e1883 --- /dev/null +++ b/src/model/mod.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod routes; diff --git a/src/models/model.rs b/src/model/models.rs index 87e1997..87e1997 100644 --- a/src/models/model.rs +++ b/src/model/models.rs diff --git a/src/routes/model.rs b/src/model/routes.rs index 58ec732..26d1bb5 100644 --- a/src/routes/model.rs +++ b/src/model/routes.rs @@ -1,14 +1,12 @@ use crate::{ + auth::models::Claims, errors::AppError, files::{delete_upload, upload}, - models::{ - auth::Claims, - likes::Like, - model::{Model, ModelCreate, ModelFilter, ModelUpload, ModelUser}, - user::User, - }, + likes::models::Like, + model::models::{Model, ModelCreate, ModelFilter, ModelUpload, ModelUser}, pagination::{ModelPagination, Pagination}, routes::JsonCreate, + user::models::User, }; use axum::{ extract::{ContentLengthLimit, Multipart, Path, Query}, diff --git a/src/models/mod.rs b/src/models/mod.rs deleted file mode 100644 index 8062fe3..0000000 --- a/src/models/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod auth; -pub mod likes; -pub mod model; -pub mod user; -pub mod warning; diff --git a/src/pagination.rs b/src/pagination.rs index 2525f06..8e61114 100644 --- a/src/pagination.rs +++ b/src/pagination.rs @@ -1,4 +1,6 @@ -use crate::models::{model::ModelUser, user::UserList, warning::WarningUser}; +use crate::model::models::ModelUser; +use crate::user::models::UserList; +use crate::warning::models::WarningUser; use serde::{Deserialize, Serialize}; #[derive(Deserialize)] diff --git a/src/routes/mod.rs b/src/routes.rs index a0e8031..a269bc4 100644 --- a/src/routes/mod.rs +++ b/src/routes.rs @@ -1,8 +1,3 @@ -pub mod auth; -pub mod model; -pub mod user; -pub mod warning; - use crate::errors::AppError; use axum::{ http::StatusCode, diff --git a/src/user/mod.rs b/src/user/mod.rs new file mode 100644 index 0000000..a0e1883 --- /dev/null +++ b/src/user/mod.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod routes; diff --git a/src/models/user.rs b/src/user/models.rs index d09394b..2ee6a06 100644 --- a/src/models/user.rs +++ b/src/user/models.rs @@ -2,7 +2,7 @@ use crate::{ config::CONFIG, db::get_client, errors::AppError, - models::model::{Model, ModelUser}, + model::models::{Model, ModelUser}, }; use serde::{Deserialize, Serialize}; diff --git a/src/routes/user.rs b/src/user/routes.rs index 31366a0..59b81a4 100644 --- a/src/routes/user.rs +++ b/src/user/routes.rs @@ -1,11 +1,9 @@ use crate::{ + auth::models::Claims, errors::AppError, files::{delete_upload, upload}, - models::{ - auth::Claims, - user::{User, UserEdit, UserList}, - }, pagination::{ModelPagination, Pagination, UserPagination}, + user::models::{User, UserEdit, UserList}, }; use axum::{ extract::{ContentLengthLimit, Multipart, Path, Query}, diff --git a/src/warning/mod.rs b/src/warning/mod.rs new file mode 100644 index 0000000..a0e1883 --- /dev/null +++ b/src/warning/mod.rs @@ -0,0 +1,2 @@ +pub mod models; +pub mod routes; diff --git a/src/models/warning.rs b/src/warning/models.rs index c420dd0..c420dd0 100644 --- a/src/models/warning.rs +++ b/src/warning/models.rs diff --git a/src/routes/warning.rs b/src/warning/routes.rs index 384218a..81173e6 100644 --- a/src/routes/warning.rs +++ b/src/warning/routes.rs @@ -1,13 +1,11 @@ use crate::{ + auth::models::Claims, errors::AppError, - models::{ - auth::Claims, - model::Model, - user::User, - warning::{Warning, WarningCreate, WarningEdit, WarningFilter, WarningFilterPayload}, - }, + model::models::Model, pagination::{Pagination, WarningPagination}, routes::JsonCreate, + user::models::User, + warning::models::*, }; use axum::{ extract::{Path, Query}, |
