Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,32 @@ impl AuthService for EthereumAddressVerificationService {
}
}
}

// Use the following to bypass signature verification

pub struct MockEthereumAddressVerificationService {}

impl MockEthereumAddressVerificationService {
pub fn new() -> Self {
Self {}
}
}

impl Default for MockEthereumAddressVerificationService {
fn default() -> Self {
Self::new()
}
}

#[async_trait]
impl AuthService for MockEthereumAddressVerificationService {
async fn verify_signature(
&self,
_challenge: &AuthChallenge,
_signature: &str,
) -> Result<Option<AuthResult>, Box<dyn std::error::Error>> {
Ok(Some(AuthResult {
wallet_address: WalletAddress("0x2581aAa94299787a8A588B2Fceb161A302939E28".to_string()),
}))
}
}
14 changes: 4 additions & 10 deletions backend/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use presentation::api::create_app;
use std::net::SocketAddr;
use std::{env, net::SocketAddr};
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};

pub mod application;
Expand All @@ -9,7 +9,8 @@ pub mod presentation;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Initialize tracing
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set");

tracing_subscriber::registry()
.with(
tracing_subscriber::EnvFilter::try_from_default_env()
Expand All @@ -18,26 +19,19 @@ async fn main() -> anyhow::Result<()> {
.with(tracing_subscriber::fmt::layer())
.init();

// Load environment variables
dotenvy::dotenv().ok();

// For development, create a mock pool
// TODO: Set up real database connection
let pool = sqlx::PgPool::connect("postgresql://localhost/guild_dev")
let pool = sqlx::PgPool::connect(&database_url)
.await
.unwrap_or_else(|_| {
tracing::warn!("Could not connect to database, using mock pool");
// Return a mock pool for now
panic!("Database connection required");
});

// Run migrations
sqlx::migrate!("./migrations").run(&pool).await?;

// Create the app
let app = create_app(pool).await;

// Run the server
let addr = SocketAddr::from(([0, 0, 0, 0], 3001));
tracing::info!("Server listening on {}", addr);

Expand Down
2 changes: 1 addition & 1 deletion backend/src/presentation/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub async fn create_app(pool: sqlx::PgPool) -> Router {
};

let protected = Router::new()
.route("/profiles/:address", post(create_profile_handler))
.route("/profiles/", post(create_profile_handler))
.route("/profiles/:address", get(get_profile_handler))
.route("/profiles/:address", put(update_profile_handler));

Expand Down
Loading