feat: make into_attr_map public
This commit is contained in:
1 parent
14d89fc696
commit
8147ec3e00
2 files changed
+7
-5
No files matched your search
@@ -10,11 +10,6 @@ use crate::pages::utils::get_user_claims;
|
|||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
use crate::pages::utils::server_utils::create_dynamo_client;
|
use crate::pages::utils::server_utils::create_dynamo_client;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
|
||||||
fn into_attr_map(map: HashMap<String, ValueType>) -> HashMap<String, aws_sdk_dynamodb::types::AttributeValue> {
|
|
||||||
map.into_iter().map(|(k, v)| (k, v.into())).collect()
|
|
||||||
}
|
|
||||||
|
|
||||||
#[server]
|
#[server]
|
||||||
async fn get_provider_contact(id: String) -> Result<HashMap<String, ValueType>, ServerFnError> {
|
async fn get_provider_contact(id: String) -> Result<HashMap<String, ValueType>, ServerFnError> {
|
||||||
use aws_sdk_dynamodb::types::AttributeValue;
|
use aws_sdk_dynamodb::types::AttributeValue;
|
||||||
@@ -54,6 +49,7 @@ async fn get_provider_contact(id: String) -> Result<HashMap<String, ValueType>,
|
|||||||
#[server]
|
#[server]
|
||||||
async fn put_provider_contact(id: String, contact_info: HashMap<String, ValueType>) -> Result<(), ServerFnError> {
|
async fn put_provider_contact(id: String, contact_info: HashMap<String, ValueType>) -> Result<(), ServerFnError> {
|
||||||
use aws_sdk_dynamodb::error::ProvideErrorMetadata;
|
use aws_sdk_dynamodb::error::ProvideErrorMetadata;
|
||||||
|
use crate::pages::utils::server_utils::into_attr_map;
|
||||||
|
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,9 @@ use crate::common::UserClaims;
|
|||||||
/// dependencies cannot be compiled for WASM (nor should they be).
|
/// dependencies cannot be compiled for WASM (nor should they be).
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
pub mod server_utils {
|
pub mod server_utils {
|
||||||
|
use std::collections::HashMap;
|
||||||
use aws_config::SdkConfig;
|
use aws_config::SdkConfig;
|
||||||
|
use crate::common::ValueType;
|
||||||
|
|
||||||
/// Creates an [`SdkConfig`] struct for use with AWS SDK structs.
|
/// Creates an [`SdkConfig`] struct for use with AWS SDK structs.
|
||||||
pub async fn create_aws_config() -> SdkConfig {
|
pub async fn create_aws_config() -> SdkConfig {
|
||||||
@@ -20,6 +22,10 @@ pub mod server_utils {
|
|||||||
pub async fn create_dynamo_client() -> aws_sdk_dynamodb::Client {
|
pub async fn create_dynamo_client() -> aws_sdk_dynamodb::Client {
|
||||||
aws_sdk_dynamodb::Client::new(&create_aws_config().await)
|
aws_sdk_dynamodb::Client::new(&create_aws_config().await)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn into_attr_map(map: HashMap<String, ValueType>) -> HashMap<String, aws_sdk_dynamodb::types::AttributeValue> {
|
||||||
|
map.into_iter().map(|(k, v)| (k, v.into())).collect()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the current user claims. This function should only be used in an area that has
|
/// Gets the current user claims. This function should only be used in an area that has
|
||||||
|
|||||||
Reference in new issue
Block a user