diff --git a/Cargo.toml b/Cargo.toml index c23b6b20..cc7fb442 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,25 +19,10 @@ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. +[workspace] +members = [ + "server", + "cli", +] -[package] -name = "fakehub" -version = "0.0.0" -edition = "2021" -license = "MIT" -description = """ -GitHub API Server Stub. Fully functional fake version of a GitHub API that -supports all the features and works locally, with no connection to GitHub at -all. -""" -authors = ["Aliaksei BialĂ­auski ", "Ivanchuk Ivan "] - -[dependencies] -anyhow = "1.0.86" -serde = { version = "1.0.203", features = ["derive"] } -serde_json = "1.0.117" -tokio = { version = "1.0.0", features = ["rt", "rt-multi-thread", "macros", "fs"] } -axum = "0.7.5" -log = { version = "0.4.21", features = [] } -env_logger = "0.11.3" -tempdir = "0.3.7" +resolver = "1" diff --git a/cli/Cargo.toml b/cli/Cargo.toml new file mode 100644 index 00000000..1e410bf2 --- /dev/null +++ b/cli/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "cli" +version = "0.1.0" +edition = "2021" + +[[bin]] +name = "fakehub-cli" +path = "src/main.rs" + +[dependencies] +server = { path = "../server" } \ No newline at end of file diff --git a/cli/src/main.rs b/cli/src/main.rs new file mode 100644 index 00000000..e7a11a96 --- /dev/null +++ b/cli/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +} diff --git a/server/Cargo.toml b/server/Cargo.toml new file mode 100644 index 00000000..be4c1443 --- /dev/null +++ b/server/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "fakehub" +version = "0.0.0" +edition = "2021" +license = "MIT" +description = """ +GitHub API Server Stub. Fully functional fake version of a GitHub API that +supports all the features and works locally, with no connection to GitHub at +all. +""" +authors = ["Aliaksei BialĂ­auski ", "Ivanchuk Ivan "] + +[lib] +path = "src/lib.rs" + +[dependencies] +anyhow = "1.0.86" +serde = { version = "1.0.203", features = ["derive"] } +serde_json = "1.0.117" +tokio = { version = "1.0.0", features = ["rt", "rt-multi-thread", "macros", "fs"] } +axum = "0.7.5" +log = { version = "0.4.21", features = [] } +env_logger = "0.11.3" +tempdir = "0.3.7" diff --git a/resources/home.json b/server/resources/home.json similarity index 100% rename from resources/home.json rename to server/resources/home.json diff --git a/src/main.rs b/server/src/lib.rs similarity index 79% rename from src/main.rs rename to server/src/lib.rs index 50bb2df1..1f079567 100644 --- a/src/main.rs +++ b/server/src/lib.rs @@ -1,3 +1,4 @@ +use axum::Router; // The MIT License (MIT) // // Copyright (c) 2024 Aliaksei Bialiauski @@ -20,16 +21,21 @@ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. use axum::routing::get; -use axum::Router; -mod routes; -mod xml; + use crate::routes::home; use crate::xml::storage::touch_storage; -#[tokio::main] -async fn main() { - touch_storage(Some("fakehub.xml")); - let app = Router::new().route("/", get(home::home)); - let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); - axum::serve(listener, app).await.unwrap(); +mod routes; +mod xml; + +#[derive(Default)] +pub struct Server {} + +impl Server { + pub async fn start() { + touch_storage(Some("fakehub.xml")); + let app = Router::new().route("/", get(home::home)); + let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap(); + axum::serve(listener, app).await.unwrap(); + } } diff --git a/src/routes/home.rs b/server/src/routes/home.rs similarity index 100% rename from src/routes/home.rs rename to server/src/routes/home.rs diff --git a/src/routes/mod.rs b/server/src/routes/mod.rs similarity index 100% rename from src/routes/mod.rs rename to server/src/routes/mod.rs diff --git a/src/routes/rs_err.rs b/server/src/routes/rs_err.rs similarity index 100% rename from src/routes/rs_err.rs rename to server/src/routes/rs_err.rs diff --git a/src/xml/mod.rs b/server/src/xml/mod.rs similarity index 100% rename from src/xml/mod.rs rename to server/src/xml/mod.rs diff --git a/src/xml/storage.rs b/server/src/xml/storage.rs similarity index 100% rename from src/xml/storage.rs rename to server/src/xml/storage.rs