Skip to content

Commit

Permalink
Rename app/services to app/persistence (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas authored Aug 6, 2024
1 parent 035d501 commit 6ec02fd
Show file tree
Hide file tree
Showing 11 changed files with 79 additions and 86 deletions.
122 changes: 57 additions & 65 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ members = ["api", "app", "doc", "models", "migration", "utils"]
[workspace.dependencies]
axum = { version = "0.7.5", default-features = false }
tower = { version = "0.4.13", default-features = false }
sea-orm = { version = "1.0.0-rc.7", default-features = false }
sea-orm = { version = "1.0.0", default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = { version = "1", default-features = false }
tracing = "0.1.40"
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Refer to [this post](https://kigawas.me/posts/rustacean-clean-architecture-appro

- [Axum](https://github.com/tokio-rs/axum) framework
- [SeaORM](https://github.com/SeaQL/sea-orm) domain models
- Completely separated API routers and DB-related logic (named "services")
- Completely separated API routers and DB-related logic (named "persistence" layer)
- Completely separated input parameters, queries and output schemas
- OpenAPI documentation ([Swagger UI](https://clean-axum.shuttleapp.rs/docs) and [Scalar](https://clean-axum.shuttleapp.rs/scalar)) powered by [Utoipa](https://github.com/juhaku/utoipa)
- Error handling with [Anyhow](https://github.com/dtolnay/anyhow)
Expand Down Expand Up @@ -41,7 +41,7 @@ Main concept: Web framework is replaceable.

All modules here should not include any specific API web framework logic.

- `app::services`: DB manipulation (CRUD) functions
- `app::persistence`: DB manipulation (CRUD) functions
- `app::config`: DB or API server configuration
- `app::state`: APP state, e.g. DB connection
- `app::error`: APP errors used by `api::error`. e.g. "User not found"
Expand All @@ -61,7 +61,7 @@ Except `models::domains` and `migration`, all modules are ORM library agnostic.
### Unit and integration tests

- `tests::api`: API integration tests. Hierarchy is the same as `api::routers`
- `tests::app`: DB/ORM-related unit tests. Hierarchy is the same as `app::services`
- `tests::app::persistence`: DB/ORM-related unit tests. Hierarchy is the same as `app::persistence`

### Others

Expand Down
2 changes: 1 addition & 1 deletion api/src/routers/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use axum::{
use sea_orm::TryIntoModel;

use app::error::UserError;
use app::services::user::{create_user, get_user, search_users};
use app::persistence::user::{create_user, get_user, search_users};
use app::state::AppState;
use models::params::user::CreateUserParams;
use models::queries::user::UserQuery;
Expand Down
2 changes: 1 addition & 1 deletion app/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pub mod config;
pub mod error;
pub mod services;
pub mod persistence;
pub mod state;
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ path = "src/lib.rs"
models = { path = "../models" }

async-std = { version = "1", features = ["attributes", "tokio1"] }
sea-orm-migration = { version = "1.0.0-rc.7" }
sea-orm-migration = { version = "1.0.0" }
Loading

0 comments on commit 6ec02fd

Please sign in to comment.