diff --git a/Workspace/Cargo.toml b/Workspace/Cargo.toml index 484ab12..20ea57c 100644 --- a/Workspace/Cargo.toml +++ b/Workspace/Cargo.toml @@ -13,5 +13,5 @@ dioxus = { {{ dioxus_dep_src }} } # workspace ui = { path = "ui" } {% if is_fullstack -%} -server = { path = "server" } +api = { path = "api" } {%- endif %} diff --git a/Workspace/README.md b/Workspace/README.md index 94c2337..8284131 100644 --- a/Workspace/README.md +++ b/Workspace/README.md @@ -1,6 +1,6 @@ # Development -{% if is_fullstack -%}Your new workspace contains a member crate for each of the web, desktop and mobile platforms, a `ui` crate for shared components and a `server` crate for shared backend logic:{%- else -%} +{% if is_fullstack -%}Your new workspace contains a member crate for each of the web, desktop and mobile platforms, a `ui` crate for shared components and a `api` crate for shared backend logic:{%- else -%} Your new workspace contains a member crate for each of the web, desktop and mobile platforms, and a `ui` crate for components that are shared between multiple platforms:{%- endif %} ``` @@ -11,7 +11,7 @@ your_project/ │ ├─ ... # Desktop specific UI/logic ├─ mobile/ │ ├─ ... # Mobile specific UI/logic{% if is_fullstack %} -├─ server/ +├─ api/ │ ├─ ... # All shared server logic{% endif %} ├─ ui/ │ ├─ ... # Component shared between multiple platforms @@ -51,10 +51,10 @@ ui/ {% if is_fullstack -%} ## Shared backend logic -The workspace contains a `server` crate with shared backend logic. This crate defines all of the shared server functions for all platforms. Server functions are async functions that expose a public API on the server. They can be called like a normal async function from the client. When you run `dx serve`, all of the server functions will be collected in the server build and hosted on a public API for the client to call. The `server` crate starts out something like this: +The workspace contains a `api` crate with shared backend logic. This crate defines all of the shared server functions for all platforms. Server functions are async functions that expose a public API on the server. They can be called like a normal async function from the client. When you run `dx serve`, all of the server functions will be collected in the server build and hosted on a public API for the client to call. The `api` crate starts out something like this: ``` -server/ +api/ ├─ src/ │ ├─ lib.rs # Exports a server function that echos the input string ``` diff --git a/Workspace/server/Cargo.toml b/Workspace/api/Cargo.toml similarity index 87% rename from Workspace/server/Cargo.toml rename to Workspace/api/Cargo.toml index 491fb6b..c525cf6 100644 --- a/Workspace/server/Cargo.toml +++ b/Workspace/api/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "server" +name = "api" version = "0.1.0" edition = "2021" diff --git a/Workspace/server/README.md b/Workspace/api/README.md similarity index 87% rename from Workspace/server/README.md rename to Workspace/api/README.md index ea6ebfc..110c02f 100644 --- a/Workspace/server/README.md +++ b/Workspace/api/README.md @@ -1,10 +1,10 @@ -# Server +# API This crate contains all shared fullstack server functions. This is a great place to place any server-only logic you would like to expose in multiple platforms like a method that accesses your database or a method that sends an email. This crate will be built twice: -1. Once for the server build with the `server` feature enabled -2. Once for the client build with the `server` feature disabled +1. Once for the server build with the `dioxus/server` feature enabled +2. Once for the client build with the client feature disabled During the server build, the server functions will be collected and hosted on a public API for the client to call. During the client build, the server functions will be compiled into the client build. diff --git a/Workspace/server/src/lib.rs b/Workspace/api/src/lib.rs similarity index 99% rename from Workspace/server/src/lib.rs rename to Workspace/api/src/lib.rs index 3962b16..87eef6e 100644 --- a/Workspace/server/src/lib.rs +++ b/Workspace/api/src/lib.rs @@ -5,4 +5,4 @@ use dioxus::prelude::*; #[server(Echo)] pub async fn echo(input: String) -> Result { Ok(input) -} \ No newline at end of file +} diff --git a/Workspace/conditional-files.rhai b/Workspace/conditional-files.rhai index d8733e1..e819ac1 100644 --- a/Workspace/conditional-files.rhai +++ b/Workspace/conditional-files.rhai @@ -5,7 +5,7 @@ const IS_ROUTER_VAR = "is_router"; let is_fullstack = variable::get(IS_FULLSTACK_VAR); if !is_fullstack { - file::delete("server"); + file::delete("api"); file::delete("ui/src/echo.rs"); file::delete("ui/assets/styling/echo.css"); } diff --git a/Workspace/ui/Cargo.toml b/Workspace/ui/Cargo.toml index 4b8381e..680d410 100644 --- a/Workspace/ui/Cargo.toml +++ b/Workspace/ui/Cargo.toml @@ -6,5 +6,5 @@ edition = "2021" [dependencies] dioxus = { workspace = true } {% if is_fullstack -%} -server = { workspace = true } +api = { workspace = true } {%- endif %} diff --git a/Workspace/ui/src/echo.rs b/Workspace/ui/src/echo.rs index caefa44..9583091 100644 --- a/Workspace/ui/src/echo.rs +++ b/Workspace/ui/src/echo.rs @@ -15,7 +15,7 @@ pub fn Echo() -> Element { input { placeholder: "Type here to echo...", oninput: move |event| async move { - let data = server::echo(event.value()).await.unwrap(); + let data = api::echo(event.value()).await.unwrap(); response.set(data); }, } diff --git a/Workspace/vars.rhai b/Workspace/vars.rhai index a76c4ca..eb0037c 100644 --- a/Workspace/vars.rhai +++ b/Workspace/vars.rhai @@ -9,7 +9,7 @@ const IS_ROUTER = "is_router"; let workspace_members = ["web", "desktop", "mobile"]; if variable::get(IS_FULLSTACK) { - workspace_members += "server" + workspace_members += "api" } variable::set(WORKSPACE_MEMBERS_VAR, workspace_members);