Commit Diff


commit - 8a6d4105aad26d11020abd2c327667419a9635f7
commit + 25c75cd07e0c46f6c4ba23c8b1ae8b2ae93e0bf2
blob - 2d9b22d8b1f015affd5667bdb36d0e593aaf7e11
blob + 60656cec3433a3c5777f95125d0b352d0805e747
--- Cargo.lock
+++ Cargo.lock
@@ -541,6 +541,8 @@ dependencies = [
  "aws-sdk-secretsmanager",
  "rocket",
  "rust-s3",
+ "serde",
+ "serde_json",
  "sqlx",
  "uuid",
 ]
blob - 3645ea5e3ffde23385f6e1e8691b0be5a5768840
blob + 57e9c02357113734251c213056e114d65adeb9a8
--- Cargo.toml
+++ Cargo.toml
@@ -9,5 +9,7 @@ aws-config = "1.5.13"
 aws-sdk-secretsmanager = "1.57.0"
 rocket = "0.5.1"
 s3 = { package = "rust-s3", version = "0.35.1", default-features = false, features = ["tokio-rustls-tls"] }
+serde = { version = "1.0.217", features = ["derive"] }
+serde_json = "1.0.135"
 sqlx = { version = "0.8.3", features = ["postgres", "runtime-tokio", "tls-rustls-ring-webpki"] }
 uuid = { version = "1.11.0", features = ["v4"] }
blob - 5a2d71bebd9d79fd8054cb3fd89c7aa8dfb1f8e3
blob + 3503a72fb83f326f02535f220d4f21cd97d4f61a
--- src/bottle.rs
+++ src/bottle.rs
@@ -5,6 +5,7 @@ use s3::{
 	bucket::Bucket,
 	creds::Credentials,
 };
+use serde::Deserialize;
 use crate::{html, html::Element, Html};
 
 pub struct BottleFuck {
@@ -13,6 +14,14 @@ pub struct BottleFuck {
 	pub css: String,
 }
 
+#[derive(Deserialize)]
+struct DbSecret {
+	username: String,
+	password: String,
+	host: String,
+	port: u16,
+}
+
 impl BottleFuck {
     pub async fn new() -> Self {
 		// Parameters for connect(): https://docs.rs/sqlx/latest/sqlx/postgres/struct.PgConnectOptions.html#parameters
@@ -33,11 +42,14 @@ impl BottleFuck {
 			.expect("secret is empty")
 			.to_string();
 		
-		println!("secret = {secret}");
+		let secret: DbSecret = serde_json::from_str(&secret)
+			.expect("failed to parse secret");
+
+		let secret = format!("postgres://{}:{}@{}:{}", secret.username, secret.password, secret.host, secret.port);
 		
 		let db = PgPoolOptions::new()
 			.max_connections(1)
-			.connect("postgres://postgres:kekkekkek@kek.chlkygx7yvp1.us-east-1.rds.amazonaws.com")
+			.connect(&secret)
 			.await
 			.expect("failed to connect to database");