Database connectivity works
All checks were successful
Rust Build / Check (pull_request) Successful in 1m55s
Rust Build / Test Suite (pull_request) Successful in 1m51s
Rust Build / Rustfmt (pull_request) Successful in 24s
Rust Build / Clippy (pull_request) Successful in 2m1s
Rust Build / build (pull_request) Successful in 3m30s

This commit is contained in:
2025-04-01 20:32:43 -04:00
parent 7fe868ec30
commit d5071ab768
3 changed files with 23 additions and 1 deletions

View File

@@ -3,5 +3,5 @@ pub mod register;
pub mod endpoints {
pub const ROOT: &str = "/";
pub const REGISTER: &str = "api/v2/register";
pub const REGISTER: &str = "/api/v2/register";
}

View File

@@ -1,3 +1,19 @@
pub mod callers;
pub mod config;
pub mod models;
pub mod db_pool {
use sqlx::postgres::PgPoolOptions;
use std::env;
pub async fn create_pool() -> Result<sqlx::PgPool, sqlx::Error> {
dotenv::dotenv().ok();
let database_url = env::var("DATABASE_URL").expect("DATABASE_URL must be set in .env");
PgPoolOptions::new()
.max_connections(10)
.connect(&database_url)
.await
}
}

View File

@@ -2,6 +2,7 @@ use axum::{
Router,
routing::{get, post},
};
// use std::net::SocketAddr;
use icarus_auth::callers;
use icarus_auth::config;
@@ -11,8 +12,13 @@ async fn main() {
// initialize tracing
tracing_subscriber::fmt::init();
let pool = icarus_auth::db_pool::create_pool()
.await
.expect("Failed to create pool");
// build our application with a route
let app = Router::new()
.layer(axum::Extension(pool))
.route(callers::endpoints::ROOT, get(callers::common::root))
.route(
callers::endpoints::REGISTER,