Skip to content

Commit

Permalink
feat: default to json for server fns
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbchron committed Mar 1, 2024
1 parent 549a0ee commit dc476ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
22 changes: 17 additions & 5 deletions crates/bl/src/fetch.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
use core_types::{PhotoGroup, PhotoThumbnailDisplayParams};
use leptos::{server, ServerFnError};
use leptos::{server, server_fn::codec::Json, ServerFnError};

#[server]
#[server(
input = Json,
output = Json,
)]
#[cfg_attr(feature = "ssr", tracing::instrument)]
pub async fn fetch_user_owned_photo_groups(
user_id: core_types::UserRecordId,
Expand Down Expand Up @@ -43,7 +46,10 @@ pub async fn fetch_user_owned_photo_groups(
})
}

#[server]
#[server(
input = Json,
output = Json,
)]
#[cfg_attr(feature = "ssr", tracing::instrument)]
pub async fn fetch_photo_group(
photo_group_id: core_types::PhotoGroupRecordId,
Expand Down Expand Up @@ -77,7 +83,10 @@ pub async fn fetch_photo_group(
})
}

#[server]
#[server(
input = Json,
output = Json,
)]
#[cfg_attr(feature = "ssr", tracing::instrument)]
pub async fn fetch_user(
user_id: core_types::UserRecordId,
Expand Down Expand Up @@ -110,7 +119,10 @@ pub async fn fetch_user(
})
}

#[server]
#[server(
input = Json,
output = Json,
)]
#[cfg_attr(feature = "ssr", tracing::instrument)]
pub async fn fetch_photo_thumbnail(
photo_id: core_types::PhotoRecordId,
Expand Down
7 changes: 5 additions & 2 deletions crates/bl/src/qr_code.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use leptos::{server, ServerFnError};
use leptos::{server, server_fn::codec::Json, ServerFnError};

/// Generate a QR code from the given data. Returns base64 encoded PNG data.
#[cfg(feature = "ssr")]
Expand All @@ -21,7 +21,10 @@ pub fn generate_qr_code_inner(data: &str) -> color_eyre::eyre::Result<String> {
Ok(data)
}

#[server]
#[server(
input = Json,
output = Json,
)]
#[cfg_attr(feature = "ssr", tracing::instrument)]
pub async fn generate_qr_code(data: String) -> Result<String, ServerFnError> {
generate_qr_code_inner(&data).map_err(|e| {
Expand Down

0 comments on commit dc476ab

Please sign in to comment.