Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
RedstoneWizard08 committed Aug 31, 2024
1 parent 6b575f6 commit 36a6387
Show file tree
Hide file tree
Showing 16 changed files with 115 additions and 3,724 deletions.
8 changes: 4 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions crates/commands/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod router;

use whcore::type_map;

type_map! {}
25 changes: 25 additions & 0 deletions crates/commands/src/router.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
use std::sync::Arc;

use data::prisma::{PrismaClient, instance, installed_mod};
use rpc_rs::{prisma_module, prisma_module_filtered, Router};

pub fn build_router() -> Router<Arc<PrismaClient>> {
let mut router = Router::new();

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

prisma_module_filtered!(router += ["mod", "mods"] {
client: PrismaClient,
module: installed_mod,
container: installed_mod,
primary_key: id,
filter: instance_id = i32,
});

router
}
2 changes: 2 additions & 0 deletions crates/core/src/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
pub mod into_async;
pub mod runnable;

pub use into_async::*;
pub use runnable::*;
6 changes: 6 additions & 0 deletions crates/core/src/traits/runnable.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
use anyhow::Result;

#[async_trait]
pub trait Runnable {
async fn run(&self) -> Result<()>;
}
8 changes: 7 additions & 1 deletion crates/data/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ use prisma_client_rust::specta::{NamedType, TypeMap};
use tokio::sync::OnceCell;
use whcore::{async_trait::async_trait, type_map};

pub use prisma::installed_mod::Data as InstalledMod;
pub use prisma::instance::Data as Instance;

#[async_trait]
pub trait DbIntoAsync<T> {
async fn db_into_async(self, client: Arc<PrismaClient>) -> T;
Expand All @@ -34,4 +37,7 @@ pub async fn get_or_init_client() -> Result<Arc<PrismaClient>> {
CLIENT.get_or_try_init(client).await.cloned()
}

type_map! {}
type_map! {
InstalledMod,
Instance,
}
Loading

0 comments on commit 36a6387

Please sign in to comment.