Argon2id password hashing, JWT access tokens with rotating HttpOnly refresh cookies and reuse detection, login rate limiting, auth audit log, bootstrap admin, admin-only user CRUD and password reset, OpenAPI spec. Vue login page, auth store with automatic token refresh, route guards, sidebar shell with toasts and placeholder pages, user management page. All tests green: 40 backend, 12 Vitest, 4 Playwright. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
18 lines
573 B
Rust
18 lines
573 B
Rust
use sqlx::sqlite::{SqlitePool, SqlitePoolOptions};
|
|
|
|
pub type DbPool = SqlitePool;
|
|
|
|
/// Connect and run migrations. In-memory URLs get a single connection so the schema persists.
|
|
pub async fn connect(url: &str) -> anyhow::Result<DbPool> {
|
|
let in_memory = url.contains(":memory:");
|
|
let pool = SqlitePoolOptions::new()
|
|
.max_connections(if in_memory { 1 } else { 5 })
|
|
.connect(url)
|
|
.await?;
|
|
sqlx::query("PRAGMA foreign_keys = ON")
|
|
.execute(&pool)
|
|
.await?;
|
|
sqlx::migrate!("./migrations").run(&pool).await?;
|
|
Ok(pool)
|
|
}
|