use crate::types::Post; use sqlx::Pool; use sqlx::Sqlite; use sqlx::{self, sqlite}; use std::collections::BTreeMap; use std::sync::Arc; use std::sync::Mutex; use uuid::Uuid; #[derive(Clone)] pub struct ServerState { // pub posts: Arc>>, pub pool: Pool, } impl ServerState { pub async fn new() -> Self { let pool = sqlite::SqlitePoolOptions::new() .max_connections(5) .connect(":memory:") .await .unwrap(); sqlx::migrate!("./migrations").run(&pool).await.unwrap(); Self { // posts: Arc::new(Mutex::new(BTreeMap::new())), pool: pool, } } }