Added modpack view

This commit is contained in:
xeovalyte 2024-06-07 14:04:19 +02:00
parent 7a8207d31d
commit cb542e07d2
No known key found for this signature in database
9 changed files with 265 additions and 75 deletions

195
Cargo.lock generated
View File

@ -86,6 +86,12 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ea50b14b7a4b9343f8c627a7a53c52076482bd4bdad0a24fd3ec533ed616cc2c" checksum = "ea50b14b7a4b9343f8c627a7a53c52076482bd4bdad0a24fd3ec533ed616cc2c"
[[package]]
name = "anyhow"
version = "1.0.86"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3d1d046238990b9cf5bcde22a3fb3584ee5cf65fb2765f454ed428c7a0063da"
[[package]] [[package]]
name = "anymap" name = "anymap"
version = "0.12.1" version = "0.12.1"
@ -701,6 +707,17 @@ dependencies = [
"nom", "nom",
] ]
[[package]]
name = "cfb"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
dependencies = [
"byteorder",
"fnv",
"uuid",
]
[[package]] [[package]]
name = "cfg-expr" name = "cfg-expr"
version = "0.15.8" version = "0.15.8"
@ -1027,7 +1044,7 @@ version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-config-macro", "dioxus-config-macro",
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-core-macro", "dioxus-core-macro",
"dioxus-fullstack", "dioxus-fullstack",
"dioxus-hooks", "dioxus-hooks",
@ -1061,6 +1078,22 @@ dependencies = [
"quote", "quote",
] ]
[[package]]
name = "dioxus-core"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "088daa3f45aaa729e9eef32dc0a9393dd709ee906b092089e5839cad1cad7c85"
dependencies = [
"futures-channel",
"futures-util",
"generational-box 0.5.1",
"longest-increasing-subsequence",
"rustc-hash",
"slab",
"tracing",
"tracing-subscriber",
]
[[package]] [[package]]
name = "dioxus-core" name = "dioxus-core"
version = "0.5.2" version = "0.5.2"
@ -1068,7 +1101,7 @@ source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5
dependencies = [ dependencies = [
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"generational-box", "generational-box 0.5.2",
"longest-increasing-subsequence", "longest-increasing-subsequence",
"rustc-hash", "rustc-hash",
"serde", "serde",
@ -1139,12 +1172,12 @@ name = "dioxus-hooks"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-debug-cell", "dioxus-debug-cell",
"dioxus-signals", "dioxus-signals",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"generational-box", "generational-box 0.5.2",
"slab", "slab",
"thiserror", "thiserror",
"tracing", "tracing",
@ -1155,7 +1188,7 @@ name = "dioxus-hot-reload"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-html", "dioxus-html",
"dioxus-rsx", "dioxus-rsx",
"interprocess-docfix", "interprocess-docfix",
@ -1169,12 +1202,12 @@ version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-html-internal-macro", "dioxus-html-internal-macro",
"enumset", "enumset",
"euclid", "euclid",
"futures-channel", "futures-channel",
"generational-box", "generational-box 0.5.2",
"keyboard-types", "keyboard-types",
"serde", "serde",
"serde-value", "serde-value",
@ -1201,7 +1234,7 @@ name = "dioxus-interpreter-js"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-html", "dioxus-html",
"js-sys", "js-sys",
"md5", "md5",
@ -1217,7 +1250,7 @@ name = "dioxus-lib"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-core-macro", "dioxus-core-macro",
"dioxus-hooks", "dioxus-hooks",
"dioxus-html", "dioxus-html",
@ -1232,13 +1265,13 @@ source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5
dependencies = [ dependencies = [
"axum", "axum",
"dioxus-cli-config", "dioxus-cli-config",
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-hot-reload", "dioxus-hot-reload",
"dioxus-html", "dioxus-html",
"dioxus-interpreter-js", "dioxus-interpreter-js",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"generational-box", "generational-box 0.5.2",
"rustc-hash", "rustc-hash",
"serde", "serde",
"serde_json", "serde_json",
@ -1299,7 +1332,7 @@ name = "dioxus-rsx"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"internment", "internment",
"krates", "krates",
"proc-macro2", "proc-macro2",
@ -1313,10 +1346,10 @@ name = "dioxus-signals"
version = "0.5.2" version = "0.5.2"
source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c" source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5844a3832ab7f038620ecf977a1c"
dependencies = [ dependencies = [
"dioxus-core", "dioxus-core 0.5.2",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"generational-box", "generational-box 0.5.2",
"once_cell", "once_cell",
"parking_lot", "parking_lot",
"rustc-hash", "rustc-hash",
@ -1331,9 +1364,9 @@ dependencies = [
"askama_escape", "askama_escape",
"async-trait", "async-trait",
"chrono", "chrono",
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-html", "dioxus-html",
"generational-box", "generational-box 0.5.2",
"http 1.1.0", "http 1.1.0",
"lru", "lru",
"rustc-hash", "rustc-hash",
@ -1350,12 +1383,12 @@ source = "git+https://github.com/DioxusLabs/dioxus.git?branch=v0.5#e2002d6ea42f5
dependencies = [ dependencies = [
"async-trait", "async-trait",
"console_error_panic_hook", "console_error_panic_hook",
"dioxus-core", "dioxus-core 0.5.2",
"dioxus-html", "dioxus-html",
"dioxus-interpreter-js", "dioxus-interpreter-js",
"futures-channel", "futures-channel",
"futures-util", "futures-util",
"generational-box", "generational-box 0.5.2",
"js-sys", "js-sys",
"rustc-hash", "rustc-hash",
"serde", "serde",
@ -1763,6 +1796,15 @@ dependencies = [
"thread_local", "thread_local",
] ]
[[package]]
name = "generational-box"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f132919c96b85c02a067ceae965fd50ace57111e2f55c7384b95ac191f4d966b"
dependencies = [
"parking_lot",
]
[[package]] [[package]]
name = "generational-box" name = "generational-box"
version = "0.5.2" version = "0.5.2"
@ -2180,6 +2222,15 @@ dependencies = [
"digest", "digest",
] ]
[[package]]
name = "home"
version = "0.5.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5"
dependencies = [
"windows-sys 0.52.0",
]
[[package]] [[package]]
name = "http" name = "http"
version = "0.2.12" version = "0.2.12"
@ -2319,6 +2370,19 @@ dependencies = [
"tokio-rustls", "tokio-rustls",
] ]
[[package]]
name = "hyper-tls"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
dependencies = [
"bytes",
"hyper 0.14.29",
"native-tls",
"tokio",
"tokio-native-tls",
]
[[package]] [[package]]
name = "hyper-tls" name = "hyper-tls"
version = "0.6.0" version = "0.6.0"
@ -2416,6 +2480,15 @@ dependencies = [
"serde", "serde",
] ]
[[package]]
name = "infer"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0a6c16b11a665b26aeeb9b1d7f954cdeb034be38dd00adab4f2ae921a8fee804"
dependencies = [
"cfb",
]
[[package]] [[package]]
name = "inout" name = "inout"
version = "0.1.3" version = "0.1.3"
@ -2721,6 +2794,46 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "manganis"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c211cfb4529c79b32307b606e83a1bb15d491b3b4a1ab97159b161d7af9d1b72"
dependencies = [
"dioxus-core 0.5.1",
"manganis-macro",
]
[[package]]
name = "manganis-common"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "542300f1e7d9313de5b7e5b92d273ba42ab547c068d773559d616aa14987de43"
dependencies = [
"anyhow",
"base64 0.21.7",
"home",
"infer",
"reqwest 0.11.27",
"serde",
"toml",
"tracing",
"url",
]
[[package]]
name = "manganis-macro"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "704a0123ac90fa630b21a04fde56c29dfd5a7665c5e8f3639567989daa2d29d1"
dependencies = [
"manganis-common",
"proc-macro2",
"quote",
"syn 2.0.66",
"tracing-subscriber",
]
[[package]] [[package]]
name = "matchit" name = "matchit"
version = "0.7.3" version = "0.7.3"
@ -3360,7 +3473,7 @@ version = "3.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284" checksum = "6d37c51ca738a55da99dc0c4a34860fd675453b8b36209178c2249bb13651284"
dependencies = [ dependencies = [
"toml_edit", "toml_edit 0.21.1",
] ]
[[package]] [[package]]
@ -3625,11 +3738,13 @@ dependencies = [
"http-body 0.4.6", "http-body 0.4.6",
"hyper 0.14.29", "hyper 0.14.29",
"hyper-rustls", "hyper-rustls",
"hyper-tls 0.5.0",
"ipnet", "ipnet",
"js-sys", "js-sys",
"log", "log",
"mime", "mime",
"mime_guess", "mime_guess",
"native-tls",
"once_cell", "once_cell",
"percent-encoding", "percent-encoding",
"pin-project-lite", "pin-project-lite",
@ -3641,6 +3756,7 @@ dependencies = [
"sync_wrapper 0.1.2", "sync_wrapper 0.1.2",
"system-configuration", "system-configuration",
"tokio", "tokio",
"tokio-native-tls",
"tokio-rustls", "tokio-rustls",
"tokio-util", "tokio-util",
"tower-service", "tower-service",
@ -3669,7 +3785,7 @@ dependencies = [
"http-body 1.0.0", "http-body 1.0.0",
"http-body-util", "http-body-util",
"hyper 1.3.1", "hyper 1.3.1",
"hyper-tls", "hyper-tls 0.6.0",
"hyper-util", "hyper-util",
"ipnet", "ipnet",
"js-sys", "js-sys",
@ -4180,6 +4296,15 @@ dependencies = [
"syn 2.0.66", "syn 2.0.66",
] ]
[[package]]
name = "serde_spanned"
version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0"
dependencies = [
"serde",
]
[[package]] [[package]]
name = "serde_urlencoded" name = "serde_urlencoded"
version = "0.7.1" version = "0.7.1"
@ -5075,11 +5200,39 @@ dependencies = [
"tokio", "tokio",
] ]
[[package]]
name = "toml"
version = "0.7.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd79e69d3b627db300ff956027cc6c3798cef26d22526befdfcd12feeb6d2257"
dependencies = [
"serde",
"serde_spanned",
"toml_datetime",
"toml_edit 0.19.15",
]
[[package]] [[package]]
name = "toml_datetime" name = "toml_datetime"
version = "0.6.6" version = "0.6.6"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf"
dependencies = [
"serde",
]
[[package]]
name = "toml_edit"
version = "0.19.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1b5bb770da30e5cbfde35a2d7b9b8a2c4b8ef89548a7a6aeab5c9a576e3e7421"
dependencies = [
"indexmap 2.2.6",
"serde",
"serde_spanned",
"toml_datetime",
"winnow",
]
[[package]] [[package]]
name = "toml_edit" name = "toml_edit"
@ -5383,6 +5536,7 @@ dependencies = [
"form_urlencoded", "form_urlencoded",
"idna", "idna",
"percent-encoding", "percent-encoding",
"serde",
] ]
[[package]] [[package]]
@ -5821,6 +5975,7 @@ dependencies = [
"axum-extra", "axum-extra",
"dioxus", "dioxus",
"dioxus-logger", "dioxus-logger",
"manganis",
"once_cell", "once_cell",
"reqwest 0.12.4", "reqwest 0.12.4",
"serde", "serde",

View File

@ -18,6 +18,7 @@ argon2 = { version = "0.5.3", optional = true }
axum = { version = "0.7.5", optional = true } axum = { version = "0.7.5", optional = true }
axum-extra = { version = "0.9.3", features = [ "cookie" ], optional = true} axum-extra = { version = "0.9.3", features = [ "cookie" ], optional = true}
reqwest = { version = "0.12", features = ["json"] } reqwest = { version = "0.12", features = ["json"] }
manganis = "0.2.2"
# Debug # Debug
tracing = "0.1.40" tracing = "0.1.40"

View File

@ -31,7 +31,7 @@ watch_path = ["src", "assets"]
# CSS style file # CSS style file
style = ["tailwind.css"] # style = ["tailwind.css"]
# Javascript code file # Javascript code file
script = [] script = []

View File

@ -1919,24 +1919,20 @@ input.tab:checked + .tab-content,
display: table; display: table;
} }
.w-full {
width: 100%;
}
.w-96 {
width: 24rem;
}
.w-\[25rem\] { .w-\[25rem\] {
width: 25rem; width: 25rem;
} }
.w-full {
width: 100%;
}
.max-w-2xl { .max-w-2xl {
max-width: 42rem; max-width: 42rem;
} }
.max-w-4xl { .max-w-7xl {
max-width: 56rem; max-width: 80rem;
} }
.max-w-lg { .max-w-lg {
@ -1947,16 +1943,8 @@ input.tab:checked + .tab-content,
max-width: 28rem; max-width: 28rem;
} }
.max-w-5xl { .max-w-xl {
max-width: 64rem; max-width: 36rem;
}
.max-w-6xl {
max-width: 72rem;
}
.max-w-7xl {
max-width: 80rem;
} }
.flex-1 { .flex-1 {
@ -1975,10 +1963,6 @@ input.tab:checked + .tab-content,
gap: 1.25rem; gap: 1.25rem;
} }
.gap-10 {
gap: 2.5rem;
}
.gap-8 { .gap-8 {
gap: 2rem; gap: 2rem;
} }
@ -2060,34 +2044,7 @@ input.tab:checked + .tab-content,
cursor: pointer; cursor: pointer;
} }
.hover\:bg-base-200:hover {
--tw-bg-opacity: 1;
background-color: var(--fallback-b2,oklch(var(--b2)/var(--tw-bg-opacity)));
}
.hover\:bg-base-200\/80:hover {
background-color: var(--fallback-b2,oklch(var(--b2)/0.8));
}
.hover\:bg-base-200\/60:hover {
background-color: var(--fallback-b2,oklch(var(--b2)/0.6));
}
.hover\:bg-base-200\/50:hover {
background-color: var(--fallback-b2,oklch(var(--b2)/0.5));
}
.hover\:bg-base-300\/100:hover {
background-color: var(--fallback-b3,oklch(var(--b3)/1));
}
.hover\:bg-base-300:hover { .hover\:bg-base-300:hover {
--tw-bg-opacity: 1; --tw-bg-opacity: 1;
background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity))); background-color: var(--fallback-b3,oklch(var(--b3)/var(--tw-bg-opacity)));
}
.hover\:shadow-xl:hover {
--tw-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
--tw-shadow-colored: 0 20px 25px -5px var(--tw-shadow-color), 0 8px 10px -6px var(--tw-shadow-color);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
} }

View File

@ -1,4 +1,7 @@
pub mod modpack;
use crate::server::modpack::Modpack; use crate::server::modpack::Modpack;
use crate::Route;
use dioxus::prelude::*; use dioxus::prelude::*;
#[component] #[component]
@ -33,7 +36,8 @@ pub struct ModpackCardProps {
#[component] #[component]
pub fn ModpackCard(props: ModpackCardProps) -> Element { pub fn ModpackCard(props: ModpackCardProps) -> Element {
rsx! { rsx! {
div { Link {
to: Route::Modpack { id: props.modpack.id },
class: "card w-[25rem] bg-base-200 hover:bg-base-300 hover:cursor-pointer shadow-xl transition-all", class: "card w-[25rem] bg-base-200 hover:bg-base-300 hover:cursor-pointer shadow-xl transition-all",
div { div {
class: "card-body", class: "card-body",

View File

@ -0,0 +1,50 @@
use dioxus::prelude::*;
use crate::server::modpack::Modpack;
#[component]
pub fn Modpack(id: String) -> Element {
let modpack = use_resource(move || {
to_owned![id];
async move { get_modpack(id).await }
});
rsx! {
div {
class: "max-w-xl w-full mx-auto",
match &*modpack.read_unchecked() {
Some(Ok(response)) => rsx! {
Modpackview { modpack: response.to_owned() }
},
Some(Err(_)) => rsx! {
"Modpack not found"
},
None => rsx! { "Loading..." },
}
}
}
}
#[component]
fn Modpackview(modpack: Modpack) -> Element {
rsx! {
h1 { class: "text-2xl font-bold mt-20", "{modpack.name}"}
div {
class: "mt-10",
"For Minecraft ",
b { "{modpack.game_version}" },
" with ",
b { "{modpack.modloader}" },
}
}
}
#[server]
async fn get_modpack(id: String) -> Result<Modpack, ServerFnError> {
use crate::server::auth::User;
User::from_cookie().await?;
Modpack::get(id).await
}

View File

@ -20,14 +20,14 @@ pub fn New() -> Element {
}); });
let submit = move |event: FormEvent| async move { let submit = move |event: FormEvent| async move {
if let Ok(_modpack_id) = create_modpack( if let Ok(modpack_id) = create_modpack(
event.values()["name"].as_value(), event.values()["name"].as_value(),
event.values()["game_version"].as_value(), event.values()["game_version"].as_value(),
event.values()["modloader"].as_value(), event.values()["modloader"].as_value(),
) )
.await .await
{ {
nav.push(Route::Modpacks {}); nav.push(Route::Modpack { id: modpack_id });
} }
}; };

View File

@ -4,10 +4,12 @@ mod modrinth;
mod server; mod server;
use dioxus::prelude::*; use dioxus::prelude::*;
use manganis::*;
use tracing::{info, Level}; use tracing::{info, Level};
use components::home::Home; use components::home::Home;
use components::layout::authenticated::Authenticated; use components::layout::authenticated::Authenticated;
use components::modpacks::modpack::Modpack;
use components::modpacks::Modpacks; use components::modpacks::Modpacks;
use components::new::New; use components::new::New;
use server::auth; use server::auth;
@ -19,6 +21,8 @@ pub enum Route {
#[layout(Authenticated)] #[layout(Authenticated)]
#[route("/modpacks")] #[route("/modpacks")]
Modpacks {}, Modpacks {},
#[route("/modpacks/:id")]
Modpack { id: String },
#[route("/new")] #[route("/new")]
New {}, New {},
#[end_layout] #[end_layout]
@ -30,6 +34,8 @@ fn main() {
// Init logger // Init logger
dioxus_logger::init(Level::INFO).expect("failed to init logger"); dioxus_logger::init(Level::INFO).expect("failed to init logger");
const _: &str = manganis::mg!(file("assets/tailwind.css"));
#[cfg(feature = "server")] #[cfg(feature = "server")]
{ {
use axum::routing::*; use axum::routing::*;

View File

@ -60,4 +60,21 @@ impl Modpack {
Ok(modpacks) Ok(modpacks)
} }
#[cfg(feature = "server")]
pub async fn get(id: String) -> Result<Self, ServerFnError> {
let mut res = DB
.query("SELECT type::string(id) as id, type::string(owner) as owner_id, name, modloader, game_version, projects FROM modpack WHERE type::string(id) = $id;")
.bind(("id", id))
.await?;
let modpack: Option<Self> = res.take(0)?;
match modpack {
Some(m) => Ok(m),
None => Err(ServerFnError::ServerError(
"Could not get modpack".to_string(),
)),
}
}
} }