Skip to content

Commit

Permalink
feat(multi-module): splitted to modules
Browse files Browse the repository at this point in the history
  • Loading branch information
l3r8yJ committed Jun 14, 2024
1 parent 73a71f9 commit 775664b
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 30 deletions.
27 changes: 6 additions & 21 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>", "Ivanchuk Ivan <[email protected]>"]

[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"
11 changes: 11 additions & 0 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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" }
3 changes: 3 additions & 0 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
24 changes: 24 additions & 0 deletions server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>", "Ivanchuk Ivan <[email protected]>"]

[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"
File renamed without changes.
24 changes: 15 additions & 9 deletions src/main.rs → server/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use axum::Router;
// The MIT License (MIT)
//
// Copyright (c) 2024 Aliaksei Bialiauski
Expand All @@ -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();
}
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 775664b

Please sign in to comment.