From 0b15f4f5e2f3caccf83ded26c3c3d6bb27b7eab7 Mon Sep 17 00:00:00 2001 From: df51d <122315498+df51d@users.noreply.github.com> Date: Tue, 23 May 2023 04:33:44 +0200 Subject: [PATCH] change: rename `core` crate to `service` in examples (#1662) * change: rename `core` crate to `service` in examples * fix(jsonrpsee-example): broken dependency --- examples/actix3_example/Cargo.toml | 2 +- examples/actix3_example/README.md | 6 +- examples/actix3_example/api/Cargo.toml | 2 +- examples/actix3_example/api/src/lib.rs | 2 +- .../service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/actix_example/Cargo.toml | 2 +- examples/actix_example/README.md | 6 +- examples/actix_example/api/Cargo.toml | 2 +- examples/actix_example/api/src/lib.rs | 2 +- .../core => actix_example/service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/axum_example/Cargo.toml | 2 +- examples/axum_example/README.md | 6 +- examples/axum_example/api/Cargo.toml | 2 +- examples/axum_example/api/src/lib.rs | 2 +- .../axum_example/{core => service}/Cargo.toml | 2 +- .../axum_example/{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../{core => service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/graphql_example/Cargo.toml | 2 +- examples/graphql_example/README.md | 6 +- examples/graphql_example/api/Cargo.toml | 2 +- examples/graphql_example/api/src/db.rs | 4 +- .../api/src/graphql/mutation/note.rs | 2 +- .../api/src/graphql/query/note.rs | 2 +- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../{core => service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/jsonrpsee_example/Cargo.toml | 2 +- examples/jsonrpsee_example/README.md | 6 +- examples/jsonrpsee_example/api/Cargo.toml | 2 +- examples/jsonrpsee_example/api/src/lib.rs | 4 +- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../jsonrpsee_example/service/tests/mock.rs | 79 +++++++++++++++++++ .../{core => service}/tests/prepare.rs | 0 examples/poem_example/Cargo.toml | 2 +- examples/poem_example/README.md | 6 +- examples/poem_example/api/Cargo.toml | 2 +- examples/poem_example/api/src/lib.rs | 2 +- .../poem_example/{core => service}/Cargo.toml | 2 +- .../poem_example/{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/rocket_example/Cargo.toml | 2 +- examples/rocket_example/README.md | 6 +- examples/rocket_example/api/Cargo.toml | 2 +- examples/rocket_example/api/src/lib.rs | 2 +- examples/rocket_example/api/src/pool.rs | 2 +- examples/rocket_example/core/tests/mock.rs | 79 ------------------- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 examples/rocket_example/service/tests/mock.rs | 79 +++++++++++++++++++ .../{core => service}/tests/prepare.rs | 0 examples/rocket_okapi_example/Cargo.toml | 2 +- examples/rocket_okapi_example/README.md | 2 +- examples/rocket_okapi_example/api/Cargo.toml | 2 +- .../api/src/okapi_example.rs | 2 +- examples/rocket_okapi_example/api/src/pool.rs | 2 +- .../rocket_okapi_example/core/tests/mock.rs | 79 ------------------- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../service/tests/mock.rs | 79 +++++++++++++++++++ .../{core => service}/tests/prepare.rs | 0 examples/salvo_example/Cargo.toml | 2 +- examples/salvo_example/README.md | 6 +- examples/salvo_example/api/Cargo.toml | 2 +- examples/salvo_example/api/src/lib.rs | 2 +- examples/salvo_example/core/tests/mock.rs | 79 ------------------- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 .../service}/tests/mock.rs | 2 +- .../{core => service}/tests/prepare.rs | 0 examples/tonic_example/Cargo.toml | 2 +- examples/tonic_example/README.md | 4 +- examples/tonic_example/api/Cargo.toml | 2 +- examples/tonic_example/api/src/lib.rs | 2 +- examples/tonic_example/core/tests/mock.rs | 79 ------------------- .../{core => service}/Cargo.toml | 2 +- .../{core => service}/src/lib.rs | 0 .../{core => service}/src/mutation.rs | 0 .../{core => service}/src/query.rs | 0 examples/tonic_example/service/tests/mock.rs | 79 +++++++++++++++++++ .../{core => service}/tests/prepare.rs | 0 issues/249/Cargo.toml | 2 +- issues/249/app/Cargo.toml | 2 +- issues/249/app/src/main.rs | 2 +- issues/249/{core => service}/Cargo.toml | 2 +- issues/249/{core => service}/src/lib.rs | 0 113 files changed, 399 insertions(+), 399 deletions(-) rename examples/{actix_example/core => actix3_example/service}/Cargo.toml (95%) rename examples/actix3_example/{core => service}/src/lib.rs (100%) rename examples/actix3_example/{core => service}/src/mutation.rs (100%) rename examples/actix3_example/{core => service}/src/query.rs (100%) rename examples/{jsonrpsee_example/core => actix3_example/service}/tests/mock.rs (97%) rename examples/actix3_example/{core => service}/tests/prepare.rs (100%) rename examples/{actix3_example/core => actix_example/service}/Cargo.toml (95%) rename examples/actix_example/{core => service}/src/lib.rs (100%) rename examples/actix_example/{core => service}/src/mutation.rs (100%) rename examples/actix_example/{core => service}/src/query.rs (100%) rename examples/{poem_example/core => actix_example/service}/tests/mock.rs (97%) rename examples/actix_example/{core => service}/tests/prepare.rs (100%) rename examples/axum_example/{core => service}/Cargo.toml (95%) rename examples/axum_example/{core => service}/src/lib.rs (100%) rename examples/axum_example/{core => service}/src/mutation.rs (100%) rename examples/axum_example/{core => service}/src/query.rs (100%) rename examples/axum_example/{core => service}/tests/mock.rs (97%) rename examples/axum_example/{core => service}/tests/prepare.rs (100%) rename examples/graphql_example/{core => service}/Cargo.toml (94%) rename examples/graphql_example/{core => service}/src/lib.rs (100%) rename examples/graphql_example/{core => service}/src/mutation.rs (100%) rename examples/graphql_example/{core => service}/src/query.rs (100%) rename examples/graphql_example/{core => service}/tests/mock.rs (97%) rename examples/graphql_example/{core => service}/tests/prepare.rs (100%) rename examples/jsonrpsee_example/{core => service}/Cargo.toml (94%) rename examples/jsonrpsee_example/{core => service}/src/lib.rs (100%) rename examples/jsonrpsee_example/{core => service}/src/mutation.rs (100%) rename examples/jsonrpsee_example/{core => service}/src/query.rs (100%) create mode 100644 examples/jsonrpsee_example/service/tests/mock.rs rename examples/jsonrpsee_example/{core => service}/tests/prepare.rs (100%) rename examples/poem_example/{core => service}/Cargo.toml (95%) rename examples/poem_example/{core => service}/src/lib.rs (100%) rename examples/poem_example/{core => service}/src/mutation.rs (100%) rename examples/poem_example/{core => service}/src/query.rs (100%) rename examples/{actix3_example/core => poem_example/service}/tests/mock.rs (97%) rename examples/poem_example/{core => service}/tests/prepare.rs (100%) delete mode 100644 examples/rocket_example/core/tests/mock.rs rename examples/rocket_example/{core => service}/Cargo.toml (94%) rename examples/rocket_example/{core => service}/src/lib.rs (100%) rename examples/rocket_example/{core => service}/src/mutation.rs (100%) rename examples/rocket_example/{core => service}/src/query.rs (100%) create mode 100644 examples/rocket_example/service/tests/mock.rs rename examples/rocket_example/{core => service}/tests/prepare.rs (100%) delete mode 100644 examples/rocket_okapi_example/core/tests/mock.rs rename examples/rocket_okapi_example/{core => service}/Cargo.toml (94%) rename examples/rocket_okapi_example/{core => service}/src/lib.rs (100%) rename examples/rocket_okapi_example/{core => service}/src/mutation.rs (100%) rename examples/rocket_okapi_example/{core => service}/src/query.rs (100%) create mode 100644 examples/rocket_okapi_example/service/tests/mock.rs rename examples/rocket_okapi_example/{core => service}/tests/prepare.rs (100%) delete mode 100644 examples/salvo_example/core/tests/mock.rs rename examples/salvo_example/{core => service}/Cargo.toml (95%) rename examples/salvo_example/{core => service}/src/lib.rs (100%) rename examples/salvo_example/{core => service}/src/mutation.rs (100%) rename examples/salvo_example/{core => service}/src/query.rs (100%) rename examples/{actix_example/core => salvo_example/service}/tests/mock.rs (97%) rename examples/salvo_example/{core => service}/tests/prepare.rs (100%) delete mode 100644 examples/tonic_example/core/tests/mock.rs rename examples/tonic_example/{core => service}/Cargo.toml (95%) rename examples/tonic_example/{core => service}/src/lib.rs (100%) rename examples/tonic_example/{core => service}/src/mutation.rs (100%) rename examples/tonic_example/{core => service}/src/query.rs (100%) create mode 100644 examples/tonic_example/service/tests/mock.rs rename examples/tonic_example/{core => service}/tests/prepare.rs (100%) rename issues/249/{core => service}/Cargo.toml (92%) rename issues/249/{core => service}/src/lib.rs (100%) diff --git a/examples/actix3_example/Cargo.toml b/examples/actix3_example/Cargo.toml index a449de4c..c6ad416a 100644 --- a/examples/actix3_example/Cargo.toml +++ b/examples/actix3_example/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] actix3-example-api = { path = "api" } diff --git a/examples/actix3_example/README.md b/examples/actix3_example/README.md index 47263826..0e65f576 100644 --- a/examples/actix3_example/README.md +++ b/examples/actix3_example/README.md @@ -6,7 +6,7 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-mysql",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-mysql",` line) 1. Execute `cargo run` to start the server @@ -19,9 +19,9 @@ cargo install systemfd systemfd --no-pid -s http::8000 -- cargo watch -x run ``` -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/actix3_example/api/Cargo.toml b/examples/actix3_example/api/Cargo.toml index 63540ec9..7d17eab2 100644 --- a/examples/actix3_example/api/Cargo.toml +++ b/examples/actix3_example/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -actix3-example-core = { path = "../core" } +actix3-example-service = { path = "../service" } actix-http = "2" actix-web = "3" actix-flash = "0.2" diff --git a/examples/actix3_example/api/src/lib.rs b/examples/actix3_example/api/src/lib.rs index 32f6f5f5..8a2be800 100644 --- a/examples/actix3_example/api/src/lib.rs +++ b/examples/actix3_example/api/src/lib.rs @@ -1,4 +1,4 @@ -use actix3_example_core::{ +use actix3_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation, Query, }; diff --git a/examples/actix_example/core/Cargo.toml b/examples/actix3_example/service/Cargo.toml similarity index 95% rename from examples/actix_example/core/Cargo.toml rename to examples/actix3_example/service/Cargo.toml index b9d49276..bdd960cc 100644 --- a/examples/actix_example/core/Cargo.toml +++ b/examples/actix3_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "actix-example-core" +name = "actix3-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/actix3_example/core/src/lib.rs b/examples/actix3_example/service/src/lib.rs similarity index 100% rename from examples/actix3_example/core/src/lib.rs rename to examples/actix3_example/service/src/lib.rs diff --git a/examples/actix3_example/core/src/mutation.rs b/examples/actix3_example/service/src/mutation.rs similarity index 100% rename from examples/actix3_example/core/src/mutation.rs rename to examples/actix3_example/service/src/mutation.rs diff --git a/examples/actix3_example/core/src/query.rs b/examples/actix3_example/service/src/query.rs similarity index 100% rename from examples/actix3_example/core/src/query.rs rename to examples/actix3_example/service/src/query.rs diff --git a/examples/jsonrpsee_example/core/tests/mock.rs b/examples/actix3_example/service/tests/mock.rs similarity index 97% rename from examples/jsonrpsee_example/core/tests/mock.rs rename to examples/actix3_example/service/tests/mock.rs index 068f31b6..bef2d1fd 100644 --- a/examples/jsonrpsee_example/core/tests/mock.rs +++ b/examples/actix3_example/service/tests/mock.rs @@ -1,7 +1,7 @@ mod prepare; +use actix3_example_service::{Mutation, Query}; use entity::post; -use jsonrpsee_example_core::{Mutation, Query}; use prepare::prepare_mock_db; #[tokio::test] diff --git a/examples/actix3_example/core/tests/prepare.rs b/examples/actix3_example/service/tests/prepare.rs similarity index 100% rename from examples/actix3_example/core/tests/prepare.rs rename to examples/actix3_example/service/tests/prepare.rs diff --git a/examples/actix_example/Cargo.toml b/examples/actix_example/Cargo.toml index 7dc877c2..ab9ab7ae 100644 --- a/examples/actix_example/Cargo.toml +++ b/examples/actix_example/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] actix-example-api = { path = "api" } diff --git a/examples/actix_example/README.md b/examples/actix_example/README.md index d844b96a..88fab093 100644 --- a/examples/actix_example/README.md +++ b/examples/actix_example/README.md @@ -4,7 +4,7 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-mysql",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-mysql",` line) 1. Execute `cargo run` to start the server @@ -17,9 +17,9 @@ cargo install systemfd cargo-watch systemfd --no-pid -s http::8000 -- cargo watch -x run ``` -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/actix_example/api/Cargo.toml b/examples/actix_example/api/Cargo.toml index a5524667..18374e70 100644 --- a/examples/actix_example/api/Cargo.toml +++ b/examples/actix_example/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -actix-example-core = { path = "../core" } +actix-example-service = { path = "../service" } actix-files = "0.6" actix-http = "3" actix-rt = "2.7" diff --git a/examples/actix_example/api/src/lib.rs b/examples/actix_example/api/src/lib.rs index 83cfa17f..f57e3e76 100644 --- a/examples/actix_example/api/src/lib.rs +++ b/examples/actix_example/api/src/lib.rs @@ -1,4 +1,4 @@ -use actix_example_core::{ +use actix_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation, Query, }; diff --git a/examples/actix3_example/core/Cargo.toml b/examples/actix_example/service/Cargo.toml similarity index 95% rename from examples/actix3_example/core/Cargo.toml rename to examples/actix_example/service/Cargo.toml index 53277a72..f9972b51 100644 --- a/examples/actix3_example/core/Cargo.toml +++ b/examples/actix_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "actix3-example-core" +name = "actix-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/actix_example/core/src/lib.rs b/examples/actix_example/service/src/lib.rs similarity index 100% rename from examples/actix_example/core/src/lib.rs rename to examples/actix_example/service/src/lib.rs diff --git a/examples/actix_example/core/src/mutation.rs b/examples/actix_example/service/src/mutation.rs similarity index 100% rename from examples/actix_example/core/src/mutation.rs rename to examples/actix_example/service/src/mutation.rs diff --git a/examples/actix_example/core/src/query.rs b/examples/actix_example/service/src/query.rs similarity index 100% rename from examples/actix_example/core/src/query.rs rename to examples/actix_example/service/src/query.rs diff --git a/examples/poem_example/core/tests/mock.rs b/examples/actix_example/service/tests/mock.rs similarity index 97% rename from examples/poem_example/core/tests/mock.rs rename to examples/actix_example/service/tests/mock.rs index e4b3ef4f..ff2f851c 100644 --- a/examples/poem_example/core/tests/mock.rs +++ b/examples/actix_example/service/tests/mock.rs @@ -1,7 +1,7 @@ mod prepare; +use actix_example_service::{Mutation, Query}; use entity::post; -use poem_example_core::{Mutation, Query}; use prepare::prepare_mock_db; #[tokio::test] diff --git a/examples/actix_example/core/tests/prepare.rs b/examples/actix_example/service/tests/prepare.rs similarity index 100% rename from examples/actix_example/core/tests/prepare.rs rename to examples/actix_example/service/tests/prepare.rs diff --git a/examples/axum_example/Cargo.toml b/examples/axum_example/Cargo.toml index 0387b657..09eafb02 100644 --- a/examples/axum_example/Cargo.toml +++ b/examples/axum_example/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] axum-example-api = { path = "api" } diff --git a/examples/axum_example/README.md b/examples/axum_example/README.md index fe120e71..49abc892 100644 --- a/examples/axum_example/README.md +++ b/examples/axum_example/README.md @@ -4,15 +4,15 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-postgres",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-postgres",` line) 1. Execute `cargo run` to start the server 1. Visit [localhost:8000](http://localhost:8000) in browser -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/axum_example/api/Cargo.toml b/examples/axum_example/api/Cargo.toml index 8b19a6da..541034e3 100644 --- a/examples/axum_example/api/Cargo.toml +++ b/examples/axum_example/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -axum-example-core = { path = "../core" } +axum-example-service = { path = "../service" } tokio = { version = "1.23.0", features = ["full"] } axum = "0.6.1" tower = "0.4.13" diff --git a/examples/axum_example/api/src/lib.rs b/examples/axum_example/api/src/lib.rs index a77a14b7..32484033 100644 --- a/examples/axum_example/api/src/lib.rs +++ b/examples/axum_example/api/src/lib.rs @@ -7,7 +7,7 @@ use axum::{ routing::{get, get_service, post}, Router, Server, }; -use axum_example_core::{ +use axum_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation as MutationCore, Query as QueryCore, }; diff --git a/examples/axum_example/core/Cargo.toml b/examples/axum_example/service/Cargo.toml similarity index 95% rename from examples/axum_example/core/Cargo.toml rename to examples/axum_example/service/Cargo.toml index 7e78682a..551f127c 100644 --- a/examples/axum_example/core/Cargo.toml +++ b/examples/axum_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "axum-example-core" +name = "axum-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/axum_example/core/src/lib.rs b/examples/axum_example/service/src/lib.rs similarity index 100% rename from examples/axum_example/core/src/lib.rs rename to examples/axum_example/service/src/lib.rs diff --git a/examples/axum_example/core/src/mutation.rs b/examples/axum_example/service/src/mutation.rs similarity index 100% rename from examples/axum_example/core/src/mutation.rs rename to examples/axum_example/service/src/mutation.rs diff --git a/examples/axum_example/core/src/query.rs b/examples/axum_example/service/src/query.rs similarity index 100% rename from examples/axum_example/core/src/query.rs rename to examples/axum_example/service/src/query.rs diff --git a/examples/axum_example/core/tests/mock.rs b/examples/axum_example/service/tests/mock.rs similarity index 97% rename from examples/axum_example/core/tests/mock.rs rename to examples/axum_example/service/tests/mock.rs index 83210530..ecbb53cb 100644 --- a/examples/axum_example/core/tests/mock.rs +++ b/examples/axum_example/service/tests/mock.rs @@ -1,6 +1,6 @@ mod prepare; -use axum_example_core::{Mutation, Query}; +use axum_example_service::{Mutation, Query}; use entity::post; use prepare::prepare_mock_db; diff --git a/examples/axum_example/core/tests/prepare.rs b/examples/axum_example/service/tests/prepare.rs similarity index 100% rename from examples/axum_example/core/tests/prepare.rs rename to examples/axum_example/service/tests/prepare.rs diff --git a/examples/graphql_example/Cargo.toml b/examples/graphql_example/Cargo.toml index c3e342dc..49229ad2 100644 --- a/examples/graphql_example/Cargo.toml +++ b/examples/graphql_example/Cargo.toml @@ -7,7 +7,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] graphql-example-api = { path = "api" } diff --git a/examples/graphql_example/README.md b/examples/graphql_example/README.md index 351c7df5..c5698a22 100644 --- a/examples/graphql_example/README.md +++ b/examples/graphql_example/README.md @@ -6,15 +6,15 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-sqlite",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-sqlite",` line) 1. Execute `cargo run` to start the server 1. Visit [localhost:3000/api/graphql](http://localhost:3000/api/graphql) in browser -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/graphql_example/api/Cargo.toml b/examples/graphql_example/api/Cargo.toml index aecf0466..1115d839 100644 --- a/examples/graphql_example/api/Cargo.toml +++ b/examples/graphql_example/api/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -graphql-example-core = { path = "../core" } +graphql-example-service = { path = "../service" } tokio = { version = "1.0", features = ["full"] } axum = "0.5.1" dotenvy = "0.15.0" diff --git a/examples/graphql_example/api/src/db.rs b/examples/graphql_example/api/src/db.rs index a1b79cd4..6db04007 100644 --- a/examples/graphql_example/api/src/db.rs +++ b/examples/graphql_example/api/src/db.rs @@ -1,4 +1,4 @@ -use graphql_example_core::sea_orm::DatabaseConnection; +use graphql_example_service::sea_orm::DatabaseConnection; pub struct Database { pub connection: DatabaseConnection, @@ -6,7 +6,7 @@ pub struct Database { impl Database { pub async fn new() -> Self { - let connection = graphql_example_core::sea_orm::Database::connect( + let connection = graphql_example_service::sea_orm::Database::connect( std::env::var("DATABASE_URL").unwrap(), ) .await diff --git a/examples/graphql_example/api/src/graphql/mutation/note.rs b/examples/graphql_example/api/src/graphql/mutation/note.rs index a3ce9f48..54f8a444 100644 --- a/examples/graphql_example/api/src/graphql/mutation/note.rs +++ b/examples/graphql_example/api/src/graphql/mutation/note.rs @@ -1,7 +1,7 @@ use async_graphql::{Context, Object, Result}; use entity::async_graphql::{self, InputObject, SimpleObject}; use entity::note; -use graphql_example_core::Mutation; +use graphql_example_service::Mutation; use crate::db::Database; diff --git a/examples/graphql_example/api/src/graphql/query/note.rs b/examples/graphql_example/api/src/graphql/query/note.rs index 1ac2549d..8ad2e0bb 100644 --- a/examples/graphql_example/api/src/graphql/query/note.rs +++ b/examples/graphql_example/api/src/graphql/query/note.rs @@ -1,6 +1,6 @@ use async_graphql::{Context, Object, Result}; use entity::{async_graphql, note}; -use graphql_example_core::Query; +use graphql_example_service::Query; use crate::db::Database; diff --git a/examples/graphql_example/core/Cargo.toml b/examples/graphql_example/service/Cargo.toml similarity index 94% rename from examples/graphql_example/core/Cargo.toml rename to examples/graphql_example/service/Cargo.toml index c9984c74..0cf7539e 100644 --- a/examples/graphql_example/core/Cargo.toml +++ b/examples/graphql_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "graphql-example-core" +name = "graphql-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/graphql_example/core/src/lib.rs b/examples/graphql_example/service/src/lib.rs similarity index 100% rename from examples/graphql_example/core/src/lib.rs rename to examples/graphql_example/service/src/lib.rs diff --git a/examples/graphql_example/core/src/mutation.rs b/examples/graphql_example/service/src/mutation.rs similarity index 100% rename from examples/graphql_example/core/src/mutation.rs rename to examples/graphql_example/service/src/mutation.rs diff --git a/examples/graphql_example/core/src/query.rs b/examples/graphql_example/service/src/query.rs similarity index 100% rename from examples/graphql_example/core/src/query.rs rename to examples/graphql_example/service/src/query.rs diff --git a/examples/graphql_example/core/tests/mock.rs b/examples/graphql_example/service/tests/mock.rs similarity index 97% rename from examples/graphql_example/core/tests/mock.rs rename to examples/graphql_example/service/tests/mock.rs index 16a56189..e049c7d3 100644 --- a/examples/graphql_example/core/tests/mock.rs +++ b/examples/graphql_example/service/tests/mock.rs @@ -1,7 +1,7 @@ mod prepare; use entity::note; -use graphql_example_core::{Mutation, Query}; +use graphql_example_service::{Mutation, Query}; use prepare::prepare_mock_db; #[tokio::test] diff --git a/examples/graphql_example/core/tests/prepare.rs b/examples/graphql_example/service/tests/prepare.rs similarity index 100% rename from examples/graphql_example/core/tests/prepare.rs rename to examples/graphql_example/service/tests/prepare.rs diff --git a/examples/jsonrpsee_example/Cargo.toml b/examples/jsonrpsee_example/Cargo.toml index 7365aa55..bf3458f4 100644 --- a/examples/jsonrpsee_example/Cargo.toml +++ b/examples/jsonrpsee_example/Cargo.toml @@ -6,7 +6,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] jsonrpsee-example-api = { path = "api" } diff --git a/examples/jsonrpsee_example/README.md b/examples/jsonrpsee_example/README.md index 4d45e5b6..0cb90752 100644 --- a/examples/jsonrpsee_example/README.md +++ b/examples/jsonrpsee_example/README.md @@ -2,7 +2,7 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-sqlite",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-sqlite",` line) 1. Execute `cargo run` to start the server @@ -63,9 +63,9 @@ curl --location --request POST 'http://127.0.0.1:8000' \ ``` -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/jsonrpsee_example/api/Cargo.toml b/examples/jsonrpsee_example/api/Cargo.toml index 6440e004..fc888391 100644 --- a/examples/jsonrpsee_example/api/Cargo.toml +++ b/examples/jsonrpsee_example/api/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -jsonrpsee-example-core = { path = "../core" } +jsonrpsee-example-service = { path = "../service" } jsonrpsee = { version = "0.8.0", features = ["full"] } jsonrpsee-core = "0.9.0" tokio = { version = "1.8.0", features = ["full"] } diff --git a/examples/jsonrpsee_example/api/src/lib.rs b/examples/jsonrpsee_example/api/src/lib.rs index 5eace0d1..de525238 100644 --- a/examples/jsonrpsee_example/api/src/lib.rs +++ b/examples/jsonrpsee_example/api/src/lib.rs @@ -6,8 +6,8 @@ use jsonrpsee::core::{async_trait, RpcResult}; use jsonrpsee::http_server::HttpServerBuilder; use jsonrpsee::proc_macros::rpc; use jsonrpsee::types::error::CallError; -use jsonrpsee_example_core::sea_orm::{Database, DatabaseConnection}; -use jsonrpsee_example_core::{Mutation, Query}; +use jsonrpsee_example_service::sea_orm::{Database, DatabaseConnection}; +use jsonrpsee_example_service::{Mutation, Query}; use log::info; use migration::{Migrator, MigratorTrait}; use simplelog::*; diff --git a/examples/jsonrpsee_example/core/Cargo.toml b/examples/jsonrpsee_example/service/Cargo.toml similarity index 94% rename from examples/jsonrpsee_example/core/Cargo.toml rename to examples/jsonrpsee_example/service/Cargo.toml index 0c3c04b9..22d8b329 100644 --- a/examples/jsonrpsee_example/core/Cargo.toml +++ b/examples/jsonrpsee_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "jsonrpsee-example-core" +name = "jsonrpsee-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/jsonrpsee_example/core/src/lib.rs b/examples/jsonrpsee_example/service/src/lib.rs similarity index 100% rename from examples/jsonrpsee_example/core/src/lib.rs rename to examples/jsonrpsee_example/service/src/lib.rs diff --git a/examples/jsonrpsee_example/core/src/mutation.rs b/examples/jsonrpsee_example/service/src/mutation.rs similarity index 100% rename from examples/jsonrpsee_example/core/src/mutation.rs rename to examples/jsonrpsee_example/service/src/mutation.rs diff --git a/examples/jsonrpsee_example/core/src/query.rs b/examples/jsonrpsee_example/service/src/query.rs similarity index 100% rename from examples/jsonrpsee_example/core/src/query.rs rename to examples/jsonrpsee_example/service/src/query.rs diff --git a/examples/jsonrpsee_example/service/tests/mock.rs b/examples/jsonrpsee_example/service/tests/mock.rs new file mode 100644 index 00000000..cb6de189 --- /dev/null +++ b/examples/jsonrpsee_example/service/tests/mock.rs @@ -0,0 +1,79 @@ +mod prepare; + +use entity::post; +use jsonrpsee_example_service::{Mutation, Query}; +use prepare::prepare_mock_db; + +#[tokio::test] +async fn main() { + let db = &prepare_mock_db(); + + { + let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); + + assert_eq!(post.id, 1); + } + + { + let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); + + assert_eq!(post.id, 5); + } + + { + let post = Mutation::create_post( + db, + post::Model { + id: 0, + title: "Title D".to_owned(), + text: "Text D".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::ActiveModel { + id: sea_orm::ActiveValue::Unchanged(6), + title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), + text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) + } + ); + } + + { + let post = Mutation::update_post_by_id( + db, + 1, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + } + ); + } + + { + let result = Mutation::delete_post(db, 5).await.unwrap(); + + assert_eq!(result.rows_affected, 1); + } + + { + let result = Mutation::delete_all_posts(db).await.unwrap(); + + assert_eq!(result.rows_affected, 5); + } +} diff --git a/examples/jsonrpsee_example/core/tests/prepare.rs b/examples/jsonrpsee_example/service/tests/prepare.rs similarity index 100% rename from examples/jsonrpsee_example/core/tests/prepare.rs rename to examples/jsonrpsee_example/service/tests/prepare.rs diff --git a/examples/poem_example/Cargo.toml b/examples/poem_example/Cargo.toml index 9024d729..226a7fd8 100644 --- a/examples/poem_example/Cargo.toml +++ b/examples/poem_example/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] poem-example-api = { path = "api" } diff --git a/examples/poem_example/README.md b/examples/poem_example/README.md index d0aa6973..f38f6e0a 100644 --- a/examples/poem_example/README.md +++ b/examples/poem_example/README.md @@ -4,15 +4,15 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-sqlite",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-sqlite",` line) 1. Execute `cargo run` to start the server 1. Visit [localhost:8000](http://localhost:8000) in browser after seeing the `server started` line -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/poem_example/api/Cargo.toml b/examples/poem_example/api/Cargo.toml index 912218ce..383843f4 100644 --- a/examples/poem_example/api/Cargo.toml +++ b/examples/poem_example/api/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -poem-example-core = { path = "../core" } +poem-example-service = { path = "../service" } tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } poem = { version = "1.2.33", features = ["static-files"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } diff --git a/examples/poem_example/api/src/lib.rs b/examples/poem_example/api/src/lib.rs index 02c7ba76..035113a7 100644 --- a/examples/poem_example/api/src/lib.rs +++ b/examples/poem_example/api/src/lib.rs @@ -8,7 +8,7 @@ use poem::http::StatusCode; use poem::listener::TcpListener; use poem::web::{Data, Form, Html, Path, Query}; use poem::{get, handler, post, EndpointExt, Error, IntoResponse, Result, Route, Server}; -use poem_example_core::{ +use poem_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation as MutationCore, Query as QueryCore, }; diff --git a/examples/poem_example/core/Cargo.toml b/examples/poem_example/service/Cargo.toml similarity index 95% rename from examples/poem_example/core/Cargo.toml rename to examples/poem_example/service/Cargo.toml index e0e57845..8f76a2f2 100644 --- a/examples/poem_example/core/Cargo.toml +++ b/examples/poem_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "poem-example-core" +name = "poem-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/poem_example/core/src/lib.rs b/examples/poem_example/service/src/lib.rs similarity index 100% rename from examples/poem_example/core/src/lib.rs rename to examples/poem_example/service/src/lib.rs diff --git a/examples/poem_example/core/src/mutation.rs b/examples/poem_example/service/src/mutation.rs similarity index 100% rename from examples/poem_example/core/src/mutation.rs rename to examples/poem_example/service/src/mutation.rs diff --git a/examples/poem_example/core/src/query.rs b/examples/poem_example/service/src/query.rs similarity index 100% rename from examples/poem_example/core/src/query.rs rename to examples/poem_example/service/src/query.rs diff --git a/examples/actix3_example/core/tests/mock.rs b/examples/poem_example/service/tests/mock.rs similarity index 97% rename from examples/actix3_example/core/tests/mock.rs rename to examples/poem_example/service/tests/mock.rs index 190cb290..6c62158c 100644 --- a/examples/actix3_example/core/tests/mock.rs +++ b/examples/poem_example/service/tests/mock.rs @@ -1,7 +1,7 @@ mod prepare; -use actix3_example_core::{Mutation, Query}; use entity::post; +use poem_example_service::{Mutation, Query}; use prepare::prepare_mock_db; #[tokio::test] diff --git a/examples/poem_example/core/tests/prepare.rs b/examples/poem_example/service/tests/prepare.rs similarity index 100% rename from examples/poem_example/core/tests/prepare.rs rename to examples/poem_example/service/tests/prepare.rs diff --git a/examples/rocket_example/Cargo.toml b/examples/rocket_example/Cargo.toml index 992ad036..d67d3df3 100644 --- a/examples/rocket_example/Cargo.toml +++ b/examples/rocket_example/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] rocket-example-api = { path = "api" } diff --git a/examples/rocket_example/README.md b/examples/rocket_example/README.md index 20845db6..023bbe2f 100644 --- a/examples/rocket_example/README.md +++ b/examples/rocket_example/README.md @@ -4,15 +4,15 @@ 1. Modify the `url` var in `api/Rocket.toml` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-postgres",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-postgres",` line) 1. Execute `cargo run` to start the server 1. Visit [localhost:8000](http://localhost:8000) in browser after seeing the `🚀 Rocket has launched from http://localhost:8000` line -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/rocket_example/api/Cargo.toml b/examples/rocket_example/api/Cargo.toml index 4361c460..bb2d5cde 100644 --- a/examples/rocket_example/api/Cargo.toml +++ b/examples/rocket_example/api/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] async-stream = { version = "0.3" } async-trait = { version = "0.1" } -rocket-example-core = { path = "../core" } +rocket-example-service = { path = "../service" } futures = { version = "0.3" } futures-util = { version = "0.3" } rocket = { version = "0.5.0-rc.1", features = [ diff --git a/examples/rocket_example/api/src/lib.rs b/examples/rocket_example/api/src/lib.rs index 29eb621d..f539d0c1 100644 --- a/examples/rocket_example/api/src/lib.rs +++ b/examples/rocket_example/api/src/lib.rs @@ -8,7 +8,7 @@ use rocket::request::FlashMessage; use rocket::response::{Flash, Redirect}; use rocket::{Build, Request, Rocket}; use rocket_dyn_templates::Template; -use rocket_example_core::{Mutation, Query}; +use rocket_example_service::{Mutation, Query}; use serde_json::json; use migration::MigratorTrait; diff --git a/examples/rocket_example/api/src/pool.rs b/examples/rocket_example/api/src/pool.rs index da8470ac..1681ca11 100644 --- a/examples/rocket_example/api/src/pool.rs +++ b/examples/rocket_example/api/src/pool.rs @@ -1,4 +1,4 @@ -use rocket_example_core::sea_orm; +use rocket_example_service::sea_orm; use async_trait::async_trait; use sea_orm::ConnectOptions; diff --git a/examples/rocket_example/core/tests/mock.rs b/examples/rocket_example/core/tests/mock.rs deleted file mode 100644 index 84b187e5..00000000 --- a/examples/rocket_example/core/tests/mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -mod prepare; - -use entity::post; -use prepare::prepare_mock_db; -use rocket_example_core::{Mutation, Query}; - -#[tokio::test] -async fn main() { - let db = &prepare_mock_db(); - - { - let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); - - assert_eq!(post.id, 1); - } - - { - let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); - - assert_eq!(post.id, 5); - } - - { - let post = Mutation::create_post( - db, - post::Model { - id: 0, - title: "Title D".to_owned(), - text: "Text D".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::ActiveModel { - id: sea_orm::ActiveValue::Unchanged(6), - title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), - text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) - } - ); - } - - { - let post = Mutation::update_post_by_id( - db, - 1, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - } - ); - } - - { - let result = Mutation::delete_post(db, 5).await.unwrap(); - - assert_eq!(result.rows_affected, 1); - } - - { - let result = Mutation::delete_all_posts(db).await.unwrap(); - - assert_eq!(result.rows_affected, 5); - } -} diff --git a/examples/rocket_example/core/Cargo.toml b/examples/rocket_example/service/Cargo.toml similarity index 94% rename from examples/rocket_example/core/Cargo.toml rename to examples/rocket_example/service/Cargo.toml index 6ee1abf9..957ad526 100644 --- a/examples/rocket_example/core/Cargo.toml +++ b/examples/rocket_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rocket-example-core" +name = "rocket-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/rocket_example/core/src/lib.rs b/examples/rocket_example/service/src/lib.rs similarity index 100% rename from examples/rocket_example/core/src/lib.rs rename to examples/rocket_example/service/src/lib.rs diff --git a/examples/rocket_example/core/src/mutation.rs b/examples/rocket_example/service/src/mutation.rs similarity index 100% rename from examples/rocket_example/core/src/mutation.rs rename to examples/rocket_example/service/src/mutation.rs diff --git a/examples/rocket_example/core/src/query.rs b/examples/rocket_example/service/src/query.rs similarity index 100% rename from examples/rocket_example/core/src/query.rs rename to examples/rocket_example/service/src/query.rs diff --git a/examples/rocket_example/service/tests/mock.rs b/examples/rocket_example/service/tests/mock.rs new file mode 100644 index 00000000..1f752615 --- /dev/null +++ b/examples/rocket_example/service/tests/mock.rs @@ -0,0 +1,79 @@ +mod prepare; + +use entity::post; +use prepare::prepare_mock_db; +use rocket_example_service::{Mutation, Query}; + +#[tokio::test] +async fn main() { + let db = &prepare_mock_db(); + + { + let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); + + assert_eq!(post.id, 1); + } + + { + let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); + + assert_eq!(post.id, 5); + } + + { + let post = Mutation::create_post( + db, + post::Model { + id: 0, + title: "Title D".to_owned(), + text: "Text D".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::ActiveModel { + id: sea_orm::ActiveValue::Unchanged(6), + title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), + text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) + } + ); + } + + { + let post = Mutation::update_post_by_id( + db, + 1, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + } + ); + } + + { + let result = Mutation::delete_post(db, 5).await.unwrap(); + + assert_eq!(result.rows_affected, 1); + } + + { + let result = Mutation::delete_all_posts(db).await.unwrap(); + + assert_eq!(result.rows_affected, 5); + } +} diff --git a/examples/rocket_example/core/tests/prepare.rs b/examples/rocket_example/service/tests/prepare.rs similarity index 100% rename from examples/rocket_example/core/tests/prepare.rs rename to examples/rocket_example/service/tests/prepare.rs diff --git a/examples/rocket_okapi_example/Cargo.toml b/examples/rocket_okapi_example/Cargo.toml index 87dfde6f..87cc8931 100644 --- a/examples/rocket_okapi_example/Cargo.toml +++ b/examples/rocket_okapi_example/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [workspace] -members = [".", "api", "core", "entity", "migration", "dto"] +members = [".", "api", "service", "entity", "migration", "dto"] [dependencies] rocket-example-api = { path = "api" } diff --git a/examples/rocket_okapi_example/README.md b/examples/rocket_okapi_example/README.md index 560baa9b..15b2c068 100644 --- a/examples/rocket_okapi_example/README.md +++ b/examples/rocket_okapi_example/README.md @@ -2,7 +2,7 @@ 1. Modify the `url` var in `api/Rocket.toml` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-postgres",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-postgres",` line) 1. Execute `cargo run` to start the server diff --git a/examples/rocket_okapi_example/api/Cargo.toml b/examples/rocket_okapi_example/api/Cargo.toml index f2e78e17..6bd5abfd 100644 --- a/examples/rocket_okapi_example/api/Cargo.toml +++ b/examples/rocket_okapi_example/api/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] async-stream = { version = "0.3" } async-trait = { version = "0.1" } -rocket-example-core = { path = "../core" } +rocket-example-service = { path = "../service" } futures = { version = "0.3" } futures-util = { version = "0.3" } rocket = { version = "0.5.0-rc.1", features = [ diff --git a/examples/rocket_okapi_example/api/src/okapi_example.rs b/examples/rocket_okapi_example/api/src/okapi_example.rs index 69d15d18..e801ffed 100644 --- a/examples/rocket_okapi_example/api/src/okapi_example.rs +++ b/examples/rocket_okapi_example/api/src/okapi_example.rs @@ -1,6 +1,6 @@ use dto::dto; use rocket::serde::json::Json; -use rocket_example_core::{Mutation, Query}; +use rocket_example_service::{Mutation, Query}; use sea_orm_rocket::Connection; diff --git a/examples/rocket_okapi_example/api/src/pool.rs b/examples/rocket_okapi_example/api/src/pool.rs index b1c05677..465ad53b 100644 --- a/examples/rocket_okapi_example/api/src/pool.rs +++ b/examples/rocket_okapi_example/api/src/pool.rs @@ -1,4 +1,4 @@ -use rocket_example_core::sea_orm; +use rocket_example_service::sea_orm; use async_trait::async_trait; use sea_orm::ConnectOptions; diff --git a/examples/rocket_okapi_example/core/tests/mock.rs b/examples/rocket_okapi_example/core/tests/mock.rs deleted file mode 100644 index 84b187e5..00000000 --- a/examples/rocket_okapi_example/core/tests/mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -mod prepare; - -use entity::post; -use prepare::prepare_mock_db; -use rocket_example_core::{Mutation, Query}; - -#[tokio::test] -async fn main() { - let db = &prepare_mock_db(); - - { - let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); - - assert_eq!(post.id, 1); - } - - { - let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); - - assert_eq!(post.id, 5); - } - - { - let post = Mutation::create_post( - db, - post::Model { - id: 0, - title: "Title D".to_owned(), - text: "Text D".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::ActiveModel { - id: sea_orm::ActiveValue::Unchanged(6), - title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), - text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) - } - ); - } - - { - let post = Mutation::update_post_by_id( - db, - 1, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - } - ); - } - - { - let result = Mutation::delete_post(db, 5).await.unwrap(); - - assert_eq!(result.rows_affected, 1); - } - - { - let result = Mutation::delete_all_posts(db).await.unwrap(); - - assert_eq!(result.rows_affected, 5); - } -} diff --git a/examples/rocket_okapi_example/core/Cargo.toml b/examples/rocket_okapi_example/service/Cargo.toml similarity index 94% rename from examples/rocket_okapi_example/core/Cargo.toml rename to examples/rocket_okapi_example/service/Cargo.toml index 6ee1abf9..957ad526 100644 --- a/examples/rocket_okapi_example/core/Cargo.toml +++ b/examples/rocket_okapi_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "rocket-example-core" +name = "rocket-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/rocket_okapi_example/core/src/lib.rs b/examples/rocket_okapi_example/service/src/lib.rs similarity index 100% rename from examples/rocket_okapi_example/core/src/lib.rs rename to examples/rocket_okapi_example/service/src/lib.rs diff --git a/examples/rocket_okapi_example/core/src/mutation.rs b/examples/rocket_okapi_example/service/src/mutation.rs similarity index 100% rename from examples/rocket_okapi_example/core/src/mutation.rs rename to examples/rocket_okapi_example/service/src/mutation.rs diff --git a/examples/rocket_okapi_example/core/src/query.rs b/examples/rocket_okapi_example/service/src/query.rs similarity index 100% rename from examples/rocket_okapi_example/core/src/query.rs rename to examples/rocket_okapi_example/service/src/query.rs diff --git a/examples/rocket_okapi_example/service/tests/mock.rs b/examples/rocket_okapi_example/service/tests/mock.rs new file mode 100644 index 00000000..1f752615 --- /dev/null +++ b/examples/rocket_okapi_example/service/tests/mock.rs @@ -0,0 +1,79 @@ +mod prepare; + +use entity::post; +use prepare::prepare_mock_db; +use rocket_example_service::{Mutation, Query}; + +#[tokio::test] +async fn main() { + let db = &prepare_mock_db(); + + { + let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); + + assert_eq!(post.id, 1); + } + + { + let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); + + assert_eq!(post.id, 5); + } + + { + let post = Mutation::create_post( + db, + post::Model { + id: 0, + title: "Title D".to_owned(), + text: "Text D".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::ActiveModel { + id: sea_orm::ActiveValue::Unchanged(6), + title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), + text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) + } + ); + } + + { + let post = Mutation::update_post_by_id( + db, + 1, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + } + ); + } + + { + let result = Mutation::delete_post(db, 5).await.unwrap(); + + assert_eq!(result.rows_affected, 1); + } + + { + let result = Mutation::delete_all_posts(db).await.unwrap(); + + assert_eq!(result.rows_affected, 5); + } +} diff --git a/examples/rocket_okapi_example/core/tests/prepare.rs b/examples/rocket_okapi_example/service/tests/prepare.rs similarity index 100% rename from examples/rocket_okapi_example/core/tests/prepare.rs rename to examples/rocket_okapi_example/service/tests/prepare.rs diff --git a/examples/salvo_example/Cargo.toml b/examples/salvo_example/Cargo.toml index aef02284..a62dc271 100644 --- a/examples/salvo_example/Cargo.toml +++ b/examples/salvo_example/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] salvo-example-api = { path = "api" } diff --git a/examples/salvo_example/README.md b/examples/salvo_example/README.md index d0aa6973..f38f6e0a 100644 --- a/examples/salvo_example/README.md +++ b/examples/salvo_example/README.md @@ -4,15 +4,15 @@ 1. Modify the `DATABASE_URL` var in `.env` to point to your chosen database -1. Turn on the appropriate database feature for your chosen db in `core/Cargo.toml` (the `"sqlx-sqlite",` line) +1. Turn on the appropriate database feature for your chosen db in `service/Cargo.toml` (the `"sqlx-sqlite",` line) 1. Execute `cargo run` to start the server 1. Visit [localhost:8000](http://localhost:8000) in browser after seeing the `server started` line -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/salvo_example/api/Cargo.toml b/examples/salvo_example/api/Cargo.toml index 0c2003ba..6635ccbe 100644 --- a/examples/salvo_example/api/Cargo.toml +++ b/examples/salvo_example/api/Cargo.toml @@ -4,7 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] -salvo-example-core = { path = "../core" } +salvo-example-service = { path = "../service" } tokio = { version = "1.15.0", features = ["macros", "rt-multi-thread"] } salvo = { version = "0.27", features = ["affix", "serve-static"] } tracing-subscriber = { version = "0.3.17", features = ["env-filter"] } diff --git a/examples/salvo_example/api/src/lib.rs b/examples/salvo_example/api/src/lib.rs index 3b7da0ba..76927c95 100644 --- a/examples/salvo_example/api/src/lib.rs +++ b/examples/salvo_example/api/src/lib.rs @@ -6,7 +6,7 @@ use salvo::extra::affix; use salvo::extra::serve_static::DirHandler; use salvo::prelude::*; use salvo::writer::Text; -use salvo_example_core::{ +use salvo_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation, Query, }; diff --git a/examples/salvo_example/core/tests/mock.rs b/examples/salvo_example/core/tests/mock.rs deleted file mode 100644 index 261652bf..00000000 --- a/examples/salvo_example/core/tests/mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -mod prepare; - -use entity::post; -use prepare::prepare_mock_db; -use salvo_example_core::{Mutation, Query}; - -#[tokio::test] -async fn main() { - let db = &prepare_mock_db(); - - { - let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); - - assert_eq!(post.id, 1); - } - - { - let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); - - assert_eq!(post.id, 5); - } - - { - let post = Mutation::create_post( - db, - post::Model { - id: 0, - title: "Title D".to_owned(), - text: "Text D".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::ActiveModel { - id: sea_orm::ActiveValue::Unchanged(6), - title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), - text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) - } - ); - } - - { - let post = Mutation::update_post_by_id( - db, - 1, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - } - ); - } - - { - let result = Mutation::delete_post(db, 5).await.unwrap(); - - assert_eq!(result.rows_affected, 1); - } - - { - let result = Mutation::delete_all_posts(db).await.unwrap(); - - assert_eq!(result.rows_affected, 5); - } -} diff --git a/examples/salvo_example/core/Cargo.toml b/examples/salvo_example/service/Cargo.toml similarity index 95% rename from examples/salvo_example/core/Cargo.toml rename to examples/salvo_example/service/Cargo.toml index a6e33269..87888a14 100644 --- a/examples/salvo_example/core/Cargo.toml +++ b/examples/salvo_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "salvo-example-core" +name = "salvo-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/salvo_example/core/src/lib.rs b/examples/salvo_example/service/src/lib.rs similarity index 100% rename from examples/salvo_example/core/src/lib.rs rename to examples/salvo_example/service/src/lib.rs diff --git a/examples/salvo_example/core/src/mutation.rs b/examples/salvo_example/service/src/mutation.rs similarity index 100% rename from examples/salvo_example/core/src/mutation.rs rename to examples/salvo_example/service/src/mutation.rs diff --git a/examples/salvo_example/core/src/query.rs b/examples/salvo_example/service/src/query.rs similarity index 100% rename from examples/salvo_example/core/src/query.rs rename to examples/salvo_example/service/src/query.rs diff --git a/examples/actix_example/core/tests/mock.rs b/examples/salvo_example/service/tests/mock.rs similarity index 97% rename from examples/actix_example/core/tests/mock.rs rename to examples/salvo_example/service/tests/mock.rs index 76531b67..13a809b8 100644 --- a/examples/actix_example/core/tests/mock.rs +++ b/examples/salvo_example/service/tests/mock.rs @@ -1,8 +1,8 @@ mod prepare; -use actix_example_core::{Mutation, Query}; use entity::post; use prepare::prepare_mock_db; +use salvo_example_service::{Mutation, Query}; #[tokio::test] async fn main() { diff --git a/examples/salvo_example/core/tests/prepare.rs b/examples/salvo_example/service/tests/prepare.rs similarity index 100% rename from examples/salvo_example/core/tests/prepare.rs rename to examples/salvo_example/service/tests/prepare.rs diff --git a/examples/tonic_example/Cargo.toml b/examples/tonic_example/Cargo.toml index d3d14704..115d1cb0 100644 --- a/examples/tonic_example/Cargo.toml +++ b/examples/tonic_example/Cargo.toml @@ -7,7 +7,7 @@ publish = false # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [workspace] -members = [".", "api", "core", "entity", "migration"] +members = [".", "api", "service", "entity", "migration"] [dependencies] tonic-example-api = { path = "api" } diff --git a/examples/tonic_example/README.md b/examples/tonic_example/README.md index 7c11feac..6cd842c2 100644 --- a/examples/tonic_example/README.md +++ b/examples/tonic_example/README.md @@ -14,9 +14,9 @@ run client using cargo run --bin client ``` -Run mock test on the core logic crate: +Run mock test on the service logic crate: ```bash -cd core +cd service cargo test --features mock ``` diff --git a/examples/tonic_example/api/Cargo.toml b/examples/tonic_example/api/Cargo.toml index 6253c531..6d1e650c 100644 --- a/examples/tonic_example/api/Cargo.toml +++ b/examples/tonic_example/api/Cargo.toml @@ -5,7 +5,7 @@ edition = "2021" publish = false [dependencies] -tonic-example-core = { path = "../core" } +tonic-example-service = { path = "../service" } tonic = "0.7" tokio = { version = "1.17", features = ["macros", "rt-multi-thread", "full"] } entity = { path = "../entity" } diff --git a/examples/tonic_example/api/src/lib.rs b/examples/tonic_example/api/src/lib.rs index 32d97981..18c27050 100644 --- a/examples/tonic_example/api/src/lib.rs +++ b/examples/tonic_example/api/src/lib.rs @@ -3,7 +3,7 @@ use tonic::{Request, Response, Status}; use entity::post; use migration::{Migrator, MigratorTrait}; -use tonic_example_core::{ +use tonic_example_service::{ sea_orm::{Database, DatabaseConnection}, Mutation, Query, }; diff --git a/examples/tonic_example/core/tests/mock.rs b/examples/tonic_example/core/tests/mock.rs deleted file mode 100644 index 522d3e45..00000000 --- a/examples/tonic_example/core/tests/mock.rs +++ /dev/null @@ -1,79 +0,0 @@ -mod prepare; - -use entity::post; -use prepare::prepare_mock_db; -use tonic_example_core::{Mutation, Query}; - -#[tokio::test] -async fn main() { - let db = &prepare_mock_db(); - - { - let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); - - assert_eq!(post.id, 1); - } - - { - let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); - - assert_eq!(post.id, 5); - } - - { - let post = Mutation::create_post( - db, - post::Model { - id: 0, - title: "Title D".to_owned(), - text: "Text D".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::ActiveModel { - id: sea_orm::ActiveValue::Unchanged(6), - title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), - text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) - } - ); - } - - { - let post = Mutation::update_post_by_id( - db, - 1, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - }, - ) - .await - .unwrap(); - - assert_eq!( - post, - post::Model { - id: 1, - title: "New Title A".to_owned(), - text: "New Text A".to_owned(), - } - ); - } - - { - let result = Mutation::delete_post(db, 5).await.unwrap(); - - assert_eq!(result.rows_affected, 1); - } - - { - let result = Mutation::delete_all_posts(db).await.unwrap(); - - assert_eq!(result.rows_affected, 5); - } -} diff --git a/examples/tonic_example/core/Cargo.toml b/examples/tonic_example/service/Cargo.toml similarity index 95% rename from examples/tonic_example/core/Cargo.toml rename to examples/tonic_example/service/Cargo.toml index 91dbcd16..fb06f9d9 100644 --- a/examples/tonic_example/core/Cargo.toml +++ b/examples/tonic_example/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "tonic-example-core" +name = "tonic-example-service" version = "0.1.0" edition = "2021" diff --git a/examples/tonic_example/core/src/lib.rs b/examples/tonic_example/service/src/lib.rs similarity index 100% rename from examples/tonic_example/core/src/lib.rs rename to examples/tonic_example/service/src/lib.rs diff --git a/examples/tonic_example/core/src/mutation.rs b/examples/tonic_example/service/src/mutation.rs similarity index 100% rename from examples/tonic_example/core/src/mutation.rs rename to examples/tonic_example/service/src/mutation.rs diff --git a/examples/tonic_example/core/src/query.rs b/examples/tonic_example/service/src/query.rs similarity index 100% rename from examples/tonic_example/core/src/query.rs rename to examples/tonic_example/service/src/query.rs diff --git a/examples/tonic_example/service/tests/mock.rs b/examples/tonic_example/service/tests/mock.rs new file mode 100644 index 00000000..6b0fbe1e --- /dev/null +++ b/examples/tonic_example/service/tests/mock.rs @@ -0,0 +1,79 @@ +mod prepare; + +use entity::post; +use prepare::prepare_mock_db; +use tonic_example_service::{Mutation, Query}; + +#[tokio::test] +async fn main() { + let db = &prepare_mock_db(); + + { + let post = Query::find_post_by_id(db, 1).await.unwrap().unwrap(); + + assert_eq!(post.id, 1); + } + + { + let post = Query::find_post_by_id(db, 5).await.unwrap().unwrap(); + + assert_eq!(post.id, 5); + } + + { + let post = Mutation::create_post( + db, + post::Model { + id: 0, + title: "Title D".to_owned(), + text: "Text D".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::ActiveModel { + id: sea_orm::ActiveValue::Unchanged(6), + title: sea_orm::ActiveValue::Unchanged("Title D".to_owned()), + text: sea_orm::ActiveValue::Unchanged("Text D".to_owned()) + } + ); + } + + { + let post = Mutation::update_post_by_id( + db, + 1, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + }, + ) + .await + .unwrap(); + + assert_eq!( + post, + post::Model { + id: 1, + title: "New Title A".to_owned(), + text: "New Text A".to_owned(), + } + ); + } + + { + let result = Mutation::delete_post(db, 5).await.unwrap(); + + assert_eq!(result.rows_affected, 1); + } + + { + let result = Mutation::delete_all_posts(db).await.unwrap(); + + assert_eq!(result.rows_affected, 5); + } +} diff --git a/examples/tonic_example/core/tests/prepare.rs b/examples/tonic_example/service/tests/prepare.rs similarity index 100% rename from examples/tonic_example/core/tests/prepare.rs rename to examples/tonic_example/service/tests/prepare.rs diff --git a/issues/249/Cargo.toml b/issues/249/Cargo.toml index cadab33f..a8f712b9 100644 --- a/issues/249/Cargo.toml +++ b/issues/249/Cargo.toml @@ -1,2 +1,2 @@ [workspace] -members = ["core", "app"] +members = ["service", "app"] diff --git a/issues/249/app/Cargo.toml b/issues/249/app/Cargo.toml index 08341381..b2f03ea3 100644 --- a/issues/249/app/Cargo.toml +++ b/issues/249/app/Cargo.toml @@ -5,5 +5,5 @@ edition = "2021" publish = false [dependencies] -core = { path = "../core" } +service = { path = "../service" } sea-orm = { path = "../../../", default-features = false, features = ["macros", "tests-cfg", "sqlx-sqlite", "runtime-async-std-native-tls"] } diff --git a/issues/249/app/src/main.rs b/issues/249/app/src/main.rs index 98fbb89d..29608459 100644 --- a/issues/249/app/src/main.rs +++ b/issues/249/app/src/main.rs @@ -1,4 +1,4 @@ -use core::clone_a_model; +use service::clone_a_model; use sea_orm::tests_cfg::cake; diff --git a/issues/249/core/Cargo.toml b/issues/249/service/Cargo.toml similarity index 92% rename from issues/249/core/Cargo.toml rename to issues/249/service/Cargo.toml index 0b741c9c..e1f96200 100644 --- a/issues/249/core/Cargo.toml +++ b/issues/249/service/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "core" +name = "service" version = "0.1.0" edition = "2021" publish = false diff --git a/issues/249/core/src/lib.rs b/issues/249/service/src/lib.rs similarity index 100% rename from issues/249/core/src/lib.rs rename to issues/249/service/src/lib.rs