almost prod product
This commit is contained in:
@@ -2,7 +2,6 @@ static DB: std::sync::OnceLock<sqlx::MySqlPool> = std::sync::OnceLock::new();
|
||||
|
||||
async fn create_pool() -> sqlx::MySqlPool {
|
||||
let database_url = std::env::var("DATABASE_URL").expect("no database url specify");
|
||||
dbg!(&database_url);
|
||||
let pool = sqlx::mysql::MySqlPoolOptions::new()
|
||||
.max_connections(4)
|
||||
.connect(database_url.as_str())
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#[cfg(feature = "ssr")]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
rust_leptos::setup::init_app(Some("Cargo.toml")).await;
|
||||
rust_leptos::setup::init_app(None).await;
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "ssr"))]
|
||||
|
||||
@@ -61,11 +61,12 @@ impl Value {
|
||||
};
|
||||
|
||||
sqlx::query!(
|
||||
"INSERT INTO donnees(service, capteur, type, donnee, date_donnee) VALUES (?, ?, ?, ?, NOW())",
|
||||
"INSERT INTO donnees(service, capteur, type, donnee, date_donnee) VALUES (?, ?, ?, ?, ?)",
|
||||
option.service,
|
||||
option.device,
|
||||
option.r_type,
|
||||
value,
|
||||
chrono::Local::now().naive_local(),
|
||||
)
|
||||
.execute(crate::database::get_db())
|
||||
.await
|
||||
|
||||
@@ -8,6 +8,7 @@ pub fn Links() -> impl IntoView {
|
||||
<ul class="flex gap-5 mt-5 justify-center">
|
||||
<Link link="aa".to_string() name="Mon Lien".to_string() />
|
||||
<Link link="aa".to_string() name="mon lien 2".to_string() />
|
||||
<Link link="aa".to_string() name="mon lien 3".to_string() />
|
||||
</ul>
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,6 @@ use leptos_axum::{generate_route_list, LeptosRoutes};
|
||||
|
||||
use crate::app::App;
|
||||
|
||||
/// # Panics
|
||||
///
|
||||
/// Will panic if anything is badly setup from database, or web server
|
||||
pub async fn init_app(configuration_path: Option<&str>) {
|
||||
tracing_subscriber::fmt()
|
||||
.with_level(true)
|
||||
@@ -24,7 +21,7 @@ pub async fn init_app(configuration_path: Option<&str>) {
|
||||
let leptos_options = conf.leptos_options;
|
||||
let serve_dir = tower_http::services::ServeDir::new(&leptos_options.site_root)
|
||||
.append_index_html_on_directories(false);
|
||||
|
||||
logging::log!("listening on http://{}", &addr);
|
||||
let app = axum::Router::new()
|
||||
.leptos_routes(&leptos_options, routes, || view! { <App/> })
|
||||
.fallback_service(serve_dir)
|
||||
|
||||
Reference in New Issue
Block a user