From 0d349da617d1ed226ee2fedc3de72460ea28f20c Mon Sep 17 00:00:00 2001 From: Tarrence van As Date: Tue, 15 Aug 2023 11:26:16 -0500 Subject: [PATCH] Refactor torii server to own crate (#774) * Remove unused deps * Refactor torii server to own crate --- Cargo.lock | 32 ++++++++++++------------ Cargo.toml | 2 +- crates/torii/{ => server}/Cargo.toml | 10 ++++---- crates/torii/{ => server}/src/cli.rs | 2 +- crates/torii/{ => server}/src/engine.rs | 0 crates/torii/{ => server}/src/indexer.rs | 0 6 files changed, 23 insertions(+), 23 deletions(-) rename crates/torii/{ => server}/Cargo.toml (85%) rename crates/torii/{ => server}/src/cli.rs (98%) rename crates/torii/{ => server}/src/engine.rs (100%) rename crates/torii/{ => server}/src/indexer.rs (100%) diff --git a/Cargo.lock b/Cargo.lock index dd201c8bc3..a406c14d0e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6702,24 +6702,16 @@ dependencies = [ ] [[package]] -name = "torii" +name = "torii-core" version = "0.1.0" dependencies = [ "anyhow", - "async-graphql", - "async-graphql-poem", "async-trait", - "base64 0.21.2", "camino", "chrono", - "clap", - "ctrlc", "dojo-types", "dojo-world", - "indexmap 1.9.3", "log", - "poem", - "scarb", "serde", "serde_json", "sqlx", @@ -6728,24 +6720,24 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", - "torii-core", - "torii-graphql", "tracing", - "tracing-subscriber", - "url", ] [[package]] -name = "torii-core" +name = "torii-graphql" version = "0.1.0" dependencies = [ "anyhow", + "async-graphql", + "async-graphql-poem", "async-trait", + "base64 0.21.2", "camino", "chrono", - "dojo-types", "dojo-world", + "indexmap 1.9.3", "log", + "poem", "serde", "serde_json", "sqlx", @@ -6754,11 +6746,13 @@ dependencies = [ "tokio", "tokio-stream", "tokio-util", + "torii-core", "tracing", + "url", ] [[package]] -name = "torii-graphql" +name = "torii-server" version = "0.1.0" dependencies = [ "anyhow", @@ -6768,10 +6762,14 @@ dependencies = [ "base64 0.21.2", "camino", "chrono", + "clap", + "ctrlc", + "dojo-types", "dojo-world", "indexmap 1.9.3", "log", "poem", + "scarb", "serde", "serde_json", "sqlx", @@ -6781,7 +6779,9 @@ dependencies = [ "tokio-stream", "tokio-util", "torii-core", + "torii-graphql", "tracing", + "tracing-subscriber", "url", ] diff --git a/Cargo.toml b/Cargo.toml index 629a4c92f9..837025fdb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ members = [ "crates/katana/core", "crates/katana/rpc", "crates/sozo", - "crates/torii", + "crates/torii/server", ] [workspace.package] diff --git a/crates/torii/Cargo.toml b/crates/torii/server/Cargo.toml similarity index 85% rename from crates/torii/Cargo.toml rename to crates/torii/server/Cargo.toml index 685a86db1d..95278954d5 100644 --- a/crates/torii/Cargo.toml +++ b/crates/torii/server/Cargo.toml @@ -1,6 +1,6 @@ [package] edition = "2021" -name = "torii" +name = "torii-server" version = "0.1.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html @@ -15,8 +15,8 @@ camino.workspace = true chrono.workspace = true clap.workspace = true ctrlc = "3.2.5" -dojo-types = { path = "../dojo-types" } -dojo-world = { path = "../dojo-world" } +dojo-types = { path = "../../dojo-types" } +dojo-world = { path = "../../dojo-world" } indexmap = "1.9.3" log = "0.4.17" poem = "1.3.48" @@ -29,8 +29,8 @@ starknet.workspace = true tokio = { version = "1.20.1", features = [ "full" ] } tokio-stream = "0.1.11" tokio-util = "0.7.7" -torii-core = { path = "./core" } -torii-graphql = { path = "./graphql" } +torii-core = { path = "../core" } +torii-graphql = { path = "../graphql" } tracing-subscriber.workspace = true tracing.workspace = true url = "2.2.2" diff --git a/crates/torii/src/cli.rs b/crates/torii/server/src/cli.rs similarity index 98% rename from crates/torii/src/cli.rs rename to crates/torii/server/src/cli.rs index 922d160164..5f08df71e1 100644 --- a/crates/torii/src/cli.rs +++ b/crates/torii/server/src/cli.rs @@ -95,7 +95,7 @@ async fn main() -> anyhow::Result<()> { let database_url = &args.database_url; #[cfg(feature = "sqlite")] let pool = SqlitePoolOptions::new().max_connections(5).connect(database_url).await?; - sqlx::migrate!().run(&pool).await?; + sqlx::migrate!("../migrations").run(&pool).await?; let provider = JsonRpcClient::new(HttpTransport::new(Url::parse(&args.rpc).unwrap())); diff --git a/crates/torii/src/engine.rs b/crates/torii/server/src/engine.rs similarity index 100% rename from crates/torii/src/engine.rs rename to crates/torii/server/src/engine.rs diff --git a/crates/torii/src/indexer.rs b/crates/torii/server/src/indexer.rs similarity index 100% rename from crates/torii/src/indexer.rs rename to crates/torii/server/src/indexer.rs