chore: change to production tables
This should be handled by environment variables in the future.
This commit is contained in:
1 parent
444e5ffb72
commit
e508e0a916
5 files changed
+20
-15
No files matched your search
@@ -1,3 +1,7 @@
|
|||||||
|
use axum::extract::State;
|
||||||
|
use axum::routing::post;
|
||||||
|
use leptos_axum::handle_server_fns_with_context;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use leptos::prelude::ServerFnError;
|
|||||||
use leptos::server;
|
use leptos::server;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
static COMPARISONS_TABLE: &str = "leptos-comparison-test";
|
static COMPARISONS_TABLE: &str = "leptos-comparisons";
|
||||||
|
|
||||||
/// Helper function to create all sports comparisons. Only used to create initial
|
/// Helper function to create all sports comparisons. Only used to create initial
|
||||||
/// comparison data, and should be removed upon completion of a comparison editor page.
|
/// comparison data, and should be removed upon completion of a comparison editor page.
|
||||||
|
|||||||
@@ -12,13 +12,16 @@ use aws_sdk_dynamodb::{
|
|||||||
Client as DynamoClient
|
Client as DynamoClient
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#[cfg(feature = "ssr")]
|
||||||
|
use crate::utils::server::create_dynamo_client;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
#[server]
|
#[server]
|
||||||
pub async fn create_dates(dates: Vec<DateInfo>) -> Result<(), ServerFnError> {
|
pub async fn create_dates(dates: Vec<DateInfo>) -> Result<(), ServerFnError> {
|
||||||
// Serialize and put dates into the database.
|
// Serialize and put dates into the database.
|
||||||
let client = expect_context::<Arc<DynamoClient>>();
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
log!("Creating dates: {:?}", dates);
|
log!("Creating dates: {:?}", dates);
|
||||||
|
|
||||||
@@ -51,7 +54,7 @@ pub async fn create_dates(dates: Vec<DateInfo>) -> Result<(), ServerFnError> {
|
|||||||
|
|
||||||
#[server]
|
#[server]
|
||||||
pub async fn get_important_dates() -> Result<Vec<DateInfo>, ServerFnError> {
|
pub async fn get_important_dates() -> Result<Vec<DateInfo>, ServerFnError> {
|
||||||
let client = expect_context::<Arc<DynamoClient>>();
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
client
|
client
|
||||||
.scan()
|
.scan()
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ use leptos::prelude::ServerFnError;
|
|||||||
use leptos::server;
|
use leptos::server;
|
||||||
|
|
||||||
#[cfg(feature = "ssr")]
|
#[cfg(feature = "ssr")]
|
||||||
static SCHOLARSHIPS_TABLE: &str = "leptos-scholarship-test";
|
static SCHOLARSHIPS_TABLE: &str = "leptos-scholarships";
|
||||||
|
|
||||||
#[server(GetScholarshipInfo, endpoint = "/scholarship/info/get")]
|
#[server(GetScholarshipInfo)]
|
||||||
pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFnError> {
|
pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFnError> {
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ pub async fn get_scholarship_info(id: String) -> Result<ExpandableInfo, ServerFn
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[server(CreateScholarshipInfo, endpoint = "/scholarship/info/create")]
|
#[server(CreateScholarshipInfo)]
|
||||||
pub async fn create_scholarship_info(info: ExpandableInfo) -> Result<(), ServerFnError> {
|
pub async fn create_scholarship_info(info: ExpandableInfo) -> Result<(), ServerFnError> {
|
||||||
use aws_sdk_dynamodb::error::ProvideErrorMetadata;
|
use aws_sdk_dynamodb::error::ProvideErrorMetadata;
|
||||||
|
|
||||||
@@ -73,7 +73,7 @@ pub async fn create_scholarship_info(info: ExpandableInfo) -> Result<(), ServerF
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[server(GetAllScholarshipInfo, endpoint = "/scholarship/info/get-all")]
|
#[server(GetAllScholarshipInfo)]
|
||||||
pub async fn get_all_scholarship_info() -> Result<Vec<ExpandableInfo>, ServerFnError> {
|
pub async fn get_all_scholarship_info() -> Result<Vec<ExpandableInfo>, ServerFnError> {
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
log!("Getting all scholarship info");
|
log!("Getting all scholarship info");
|
||||||
@@ -98,7 +98,7 @@ pub async fn get_all_scholarship_info() -> Result<Vec<ExpandableInfo>, ServerFnE
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Gets all scholarships that are associated with the given scholarship provider's ID.
|
/// Gets all scholarships that are associated with the given scholarship provider's ID.
|
||||||
#[server(GetProviderScholarships, "/providers/scholarships/get")]
|
#[server(GetProviderScholarships)]
|
||||||
pub async fn get_provider_scholarships(provider_id: String) -> Result<Vec<ExpandableInfo>, ServerFnError> {
|
pub async fn get_provider_scholarships(provider_id: String) -> Result<Vec<ExpandableInfo>, ServerFnError> {
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
@@ -127,16 +127,15 @@ pub async fn get_provider_scholarships(provider_id: String) -> Result<Vec<Expand
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a new scholarship with a unique ID, and then returns that ID.
|
/// Creates a new scholarship with a unique ID, and then returns that ID.
|
||||||
#[server(RegisterScholarship, "/providers/scholarships/create")]
|
#[server(RegisterScholarship)]
|
||||||
pub async fn register_scholarship(provider_id: String, scholarship_name: String) -> Result<String, ServerFnError> {
|
pub async fn register_scholarship(provider_id: String) -> Result<String, ServerFnError> {
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
log!("Creating scholarship for provider with ID {:?}", provider_id);
|
log!("Creating scholarship for provider with ID {:?}", provider_id);
|
||||||
|
|
||||||
let mut current_uuid = "testing".to_string();
|
let mut current_uuid = Uuid::new_v4().to_string();
|
||||||
let mut item = ExpandableInfo::new(current_uuid.clone());
|
let mut item = ExpandableInfo::new(current_uuid.clone());
|
||||||
item.data.insert("provider_id".to_string(), ValueType::String(Some(provider_id)));
|
item.data.insert("provider_id".to_string(), ValueType::String(Some(provider_id)));
|
||||||
item.data.insert("scholarship_name".to_string(), ValueType::String(Some(scholarship_name)));
|
|
||||||
loop {
|
loop {
|
||||||
let ser_item = serde_dynamo::to_item(&item)?;
|
let ser_item = serde_dynamo::to_item(&item)?;
|
||||||
match client
|
match client
|
||||||
@@ -172,7 +171,7 @@ pub async fn register_scholarship(provider_id: String, scholarship_name: String)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Deletes a provider's scholarship given their provider ID and scholarship ID.
|
/// Deletes a provider's scholarship given their provider ID and scholarship ID.
|
||||||
#[server(DeleteProviderScholarship, "/providers/scholarships/delete")]
|
#[server(DeleteProviderScholarship)]
|
||||||
pub async fn delete_provider_scholarship(provider_id: String, scholarship_id: String) -> Result<(), ServerFnError> {
|
pub async fn delete_provider_scholarship(provider_id: String, scholarship_id: String) -> Result<(), ServerFnError> {
|
||||||
let client = create_dynamo_client().await;
|
let client = create_dynamo_client().await;
|
||||||
|
|
||||||
|
|||||||
@@ -128,8 +128,7 @@ fn ScholarshipList(
|
|||||||
// Button handlers
|
// Button handlers
|
||||||
let create_on_click = move |_| {
|
let create_on_click = move |_| {
|
||||||
create_action.dispatch(RegisterScholarship {
|
create_action.dispatch(RegisterScholarship {
|
||||||
provider_id: provider_id.get().unwrap(),
|
provider_id: provider_id.get().unwrap()
|
||||||
scholarship_name: "Testing Scholarship".to_string()
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user