chore: remove sqlx dependency from Cargo.toml and Cargo.lock

This commit is contained in:
2026-01-02 13:14:24 +01:00
parent ff40174734
commit 61202c5969
3 changed files with 1 additions and 19 deletions

1
Cargo.lock generated
View File

@@ -49,7 +49,6 @@ dependencies = [
"password-auth",
"serde",
"serde_json",
"sqlx",
"thiserror 2.0.17",
"time",
"tokio",

View File

@@ -9,12 +9,10 @@ default = ["sqlite"]
sqlite = [
"infra/sqlite",
"tower-sessions-sqlx-store/sqlite",
"sqlx/sqlite",
]
postgres = [
"infra/postgres",
"tower-sessions-sqlx-store/postgres",
"sqlx/postgres",
"k-core/postgres",
]
broker-nats = ["infra/broker-nats"]
@@ -65,7 +63,6 @@ tracing = "0.1"
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
# Database
sqlx = { version = "0.8.6", features = ["sqlite", "runtime-tokio"] }
dotenvy = "0.15.7"
# Configuration

View File

@@ -21,52 +21,38 @@ use crate::state::AppState;
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// 1. Initialize logging
logging::init("template-api");
logging::init("api");
// 2. Load configuration
// We use dotenvy explicitly here since config crate might not pick up .env automatically reliably
dotenvy::dotenv().ok();
let config = Config::new().expect("Failed to load configuration");
info!("Starting server on {}:{}", config.host, config.port);
// 3. Connect to database
// k-core handles the "Which DB are we using?" logic internally based on feature flags
// and returns the correct Enum variant.
let db_config = k_core::db::DatabaseConfig {
url: config.database_url.clone(),
max_connections: 5,
acquire_timeout: StdDuration::from_secs(30),
};
// Returns k_core::db::DatabasePool
let db_pool = k_core::db::connect(&db_config).await?;
// 4. Run migrations (using the re-export if you kept it, or direct k_core)
infra::db::run_migrations(&db_pool).await?;
// 5. Initialize Services
let user_repo = build_user_repository(&db_pool).await?;
let user_service = UserService::new(user_repo.clone());
// 6. Setup Session Store
let session_store = build_session_store(&db_pool).await?;
let session_layer = SessionManagerLayer::new(session_store)
.with_secure(false) // Set to true in production with HTTPS
.with_expiry(Expiry::OnInactivity(time::Duration::hours(1)));
// 7. Setup Auth
let auth_layer = auth::setup_auth_layer(session_layer, user_repo.clone()).await?;
// 8. Create App State
let state = AppState::new(user_service, config.clone());
// 9. Build Router
let app = routes::api_v1_router().layer(auth_layer).with_state(state);
// 10. Start Server
let addr: SocketAddr = format!("{}:{}", config.host, config.port).parse()?;
let listener = TcpListener::bind(addr).await?;
axum::serve(listener, app).await?;