Skip to content

Commit

Permalink
Finishing db router stuff and custom prisma client for rpc-rs
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Jul 6, 2024
1 parent c1e8f9d commit 86a86be
Show file tree
Hide file tree
Showing 316 changed files with 41,929 additions and 251 deletions.
1,298 changes: 1,277 additions & 21 deletions Cargo.lock

Large diffs are not rendered by default.

67 changes: 57 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ edition = "2021"
license = "MIT"
repository = "https://github.com/RedstoneWizard08/Wormhole"
homepage = "https://github.com/RedstoneWizard08/Wormhole"
authors = ["RedstoneWizard08", "Rexicon226", "cheese3660", "Wormhole Contributors"]
authors = [
"RedstoneWizard08",
"Rexicon226",
"cheese3660",
"Wormhole Contributors",
]

[workspace.dependencies]
tokio = { version = "1.37.0", features = ["full"] }
Expand All @@ -13,9 +18,19 @@ serde = { version = "1.0.202", features = ["derive"] }
tauri = { version = "1.6.6", features = ["api-all"] }
zip-extensions = "0.8.0"
keyvalues-parser = "0.2.0"
reqwest = { version = "0.12.4", features = ["json", "stream", "gzip", "rustls-tls"], default-features = false }
reqwest = { version = "0.12.4", features = [
"json",
"stream",
"gzip",
"rustls-tls",
], default-features = false }
tokio-util = { version = "0.7.11", features = ["full"] }
tokio-stream = { version = "0.1.15", features = ["tokio-util", "fs", "net", "sync"] }
tokio-stream = { version = "0.1.15", features = [
"tokio-util",
"fs",
"net",
"sync",
] }
tauri-build = "1.5.2"
clap = { version = "4.5.4", features = ["derive", "env", "string"] }
rand = "0.8.5"
Expand All @@ -29,7 +44,13 @@ phf = { version = "0.11.2", features = ["macros"] }
flate2 = "1.0.30"
dirs = "5.0.1"
tracing = { version = "0.1.40", features = ["log", "async-await"] }
tracing-subscriber = { version = "0.3.18", features = ["tracing", "env-filter", "json", "chrono", "serde"] }
tracing-subscriber = { version = "0.3.18", features = [
"tracing",
"env-filter",
"json",
"chrono",
"serde",
] }
cfg-if = "1.0.0"
tar = "0.4.40"
xz = "0.1.0"
Expand All @@ -38,7 +59,11 @@ base64 = "0.22.1"
ferinth = "2.11.0"
furse = "1.5.15"
tempfile = "3.10.1"
specta = { version = "2.0.0-rc.13", features = ["function", "typescript", "export"] }
specta = { version = "2.0.0-rc.13", features = [
"function",
"typescript",
"export",
] }
futures = { version = "0.3.30", features = ["executor"] }
axum = { version = "0.7.5", features = ["macros", "ws"] }
mime_guess = "2.0.4"
Expand All @@ -50,7 +75,9 @@ ctrlc = { version = "3.4.4", features = ["termination"] }
include_dir = "0.7.4"
axum-core = "0.4.3"
bytes = "1.6.0"
futures-util = { version = "0.3.30", default-features = false, features = ["alloc"] }
futures-util = { version = "0.3.30", default-features = false, features = [
"alloc",
] }
hyper = "1.3.1"
hyper-util = { version = "0.1.5", features = ["tokio"] }
sha-1 = "0.10.1"
Expand Down Expand Up @@ -80,9 +107,26 @@ libc = "0.2.155"
thiserror = "1.0.61"
murmur2 = "0.1.0"
serde_repr = "0.1.19"
tungstenite = { features = ["rustls"], git = "https://github.com/snapview/tungstenite-rs", version = "0.20.1", rev = "fc17f73" }
prisma-client-rust = { git = "https://github.com/Brendonovich/prisma-client-rust", rev = "4f9ef9d", features = ["specta", "sqlite"] }
prisma-client-rust-cli = { git = "https://github.com/Brendonovich/prisma-client-rust", rev = "4f9ef9d", features = ["specta", "sqlite"] }
tungstenite = { features = [
"rustls",
], git = "https://github.com/snapview/tungstenite-rs", version = "0.20.1", rev = "fc17f73" }
convert_case = "0.6.0"
diagnostics = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
dmmf = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
prisma-models = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
psl = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
query-core = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
schema-core = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
request-handlers = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
user-facing-errors = { git = "https://github.com/Brendonovich/prisma-engines", branch = "5.1.0-patched" }
prisma-client-rust = { path = "./external/prisma-client-rust/crates/lib", features = [
"specta",
"sqlite",
] }
prisma-client-rust-cli = { path = "./external/prisma-client-rust/crates/cli", features = [
"specta",
"sqlite",
] }

wormhole-cli = { path = "./apps/cli" }
wormhole-gui = { path = "./apps/gui" }
Expand Down Expand Up @@ -135,5 +179,8 @@ members = [
"crates/commands",
"crates/plugins",
"crates/pack",
"tools/prisma", "crates/rpc-rs",
"tools/prisma",
"crates/rpc-rs",
"external/prisma-client-rust/crates/lib",
"external/prisma-client-rust/crates/cli",
]
2 changes: 1 addition & 1 deletion apps/bindings/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct Cli {
impl Runnable for Cli {
async fn run(&self) -> Result<()> {
println!("Exporting app bindings...");

build_router().export("/rpc", self.path.clone())?;

Ok(())
Expand Down
59 changes: 38 additions & 21 deletions crates/commands/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,45 @@
use std::sync::Arc;

use data::prisma::PrismaClient;
use rpc_rs::{module::module::Module, proc::wrap, router::router::Router};
use data::prisma::{game, instance, r#mod, source, PrismaClient};
use rpc_rs::{module::module::Module, prisma_module, proc::wrap, router::router::Router};

/// Create a router.
pub fn build_router() -> Router<Arc<PrismaClient>> {
Router::<Arc<PrismaClient>>::new()
.mount(
"version",
Module::builder()
.read(wrap(|_cx, _: ()| async move { env!("CARGO_PKG_VERSION") }))
.build(),
)
.mount(
"mods",
Module::builder()
.read(wrap(|cx: Arc<PrismaClient>, _: ()| async move {
cx.r#mod()
.find_many(vec![])
.exec()
.await
.unwrap_or_default()
}))
.build(),
)
let mut router = Router::<Arc<PrismaClient>>::new().mount(
"version",
Module::builder()
.read(wrap(|_cx, _: ()| async move { env!("CARGO_PKG_VERSION") }))
.build(),
);

prisma_module!(router += ["mod", "mods"] {
client: PrismaClient,
module: r#mod,
container: r#mod,
primary_key: id,
});

prisma_module!(router += ["game", "games"] {
client: PrismaClient,
module: game,
container: game,
primary_key: id,
});

prisma_module!(router += ["source", "sources"] {
client: PrismaClient,
module: source,
container: source,
primary_key: id,
});

prisma_module!(router += ["instance", "instances"] {
client: PrismaClient,
module: instance,
container: instance,
primary_key: id,
});

router
}
Loading

0 comments on commit 86a86be

Please sign in to comment.