Skip to content

Commit

Permalink
maybe working
Browse files Browse the repository at this point in the history
  • Loading branch information
benthecarman committed Sep 23, 2023
1 parent c65735f commit 9371a01
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 99 deletions.
138 changes: 102 additions & 36 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ sha2 = { version = "0.10", default-features = false }
serde = { version = "^1.0", features = ["derive"] }
serde_json = "1.0.67"
tokio = { version = "1.12.0", features = ["full"] }
tokio-postgres = { version = "0.7.10", features = ["with-chrono-0_4"] }
tokio-postgres = { git = "https://github.com/prisma/rust-postgres", branch = "pgbouncer-mode", features = ["with-chrono-0_4"] }
tower-http = { version = "0.4.0", features = ["cors"] }

ureq = { version = "2.5.0", features = ["json"] }
postgres-openssl = "0.5.0"
openssl = "0.10.57"
postgres-native-tls = { git = "https://github.com/prisma/rust-postgres", branch = "pgbouncer-mode" }
native-tls = "0.2"
17 changes: 10 additions & 7 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ use axum::headers::Origin;
use axum::http::{request::Parts, HeaderValue, Method, StatusCode, Uri};
use axum::routing::{get, post, put};
use axum::{http, Extension, Router, TypedHeader};
use openssl::ssl::{SslConnector, SslMethod};
use postgres_openssl::MakeTlsConnector;
use native_tls::TlsConnector;
use postgres_native_tls::MakeTlsConnector;
use secp256k1::{All, PublicKey, Secp256k1};
use std::str::FromStr;
use std::sync::Arc;
use tokio_postgres::Client;
use tokio_postgres::{Client, Config};
use tower_http::cors::{AllowOrigin, CorsLayer};

mod auth;
Expand Down Expand Up @@ -53,17 +54,19 @@ async fn main() -> anyhow::Result<()> {
let auth_key_bytes = hex::decode(auth_key)?;
let auth_key = PublicKey::from_slice(&auth_key_bytes)?;

let builder = SslConnector::builder(SslMethod::tls())?;
let connector = MakeTlsConnector::new(builder.build());
let tls = TlsConnector::new()?;
let connector = MakeTlsConnector::new(tls);

// Connect to the database.
let (client, connection) = tokio_postgres::connect(&pg_url, connector).await?;
let mut config = Config::from_str(&pg_url).unwrap();
config.pgbouncer_mode(true);
let (client, connection) = config.connect(connector).await?;

// The connection object performs the actual communication with the database,
// so spawn it off to run on its own.
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("db connection error: {e}");
panic!("db connection error: {e}");
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/models/migration_baseline.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CREATE TABLE vss_db
CREATE TABLE IF NOT EXISTS vss_db
(
store_id TEXT NOT NULL CHECK (store_id != ''),
key TEXT NOT NULL,
Expand Down
Loading

0 comments on commit 9371a01

Please sign in to comment.