From d64580df0e5980e874ee051e40538ceb8546b84e Mon Sep 17 00:00:00 2001 From: David Westgate Date: Mon, 27 May 2024 13:00:13 -0700 Subject: [PATCH] rename store to json store --- src/api.rs | 2 +- src/{store.rs => json_store.rs} | 0 src/main.rs | 10 +++++----- 3 files changed, 6 insertions(+), 6 deletions(-) rename src/{store.rs => json_store.rs} (100%) diff --git a/src/api.rs b/src/api.rs index 164afdd..fe7a6bf 100644 --- a/src/api.rs +++ b/src/api.rs @@ -1,5 +1,5 @@ /// All API route handlers of the application -use self::{answer::AnswerDTO, question::QuestionDTO, store::Store}; +use self::{answer::AnswerDTO, question::QuestionDTO, json_store::Store}; use crate::*; const DEFAULT_PAGE: usize = 0; const DEFAULT_PAGE_SIZE: usize = 10; diff --git a/src/store.rs b/src/json_store.rs similarity index 100% rename from src/store.rs rename to src/json_store.rs diff --git a/src/main.rs b/src/main.rs index 0f5e22a..9390cd5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ mod answer; mod api; mod question; -mod store; +mod json_store; use axum::{ extract::{Path, Query, State}, http::{StatusCode, Uri}, @@ -24,7 +24,7 @@ use std::{ path::PathBuf, sync::Arc, }; -use store::Store; +use json_store::Store; use tokio::sync::RwLock; // generic handler for any not supported route/method combination @@ -56,18 +56,18 @@ async fn serve_file(uri: Uri) -> impl IntoResponse { async fn db_connection() -> Result, sqlx::Error> { let url: String = format!( - "postgres://{}:{}@{}:5432/{}", + "postgres://{}:{}@{}:5432"/*{}*/, var("POSTGRES_USER").unwrap(), var("POSTGRES_PASSWORD").unwrap(), var("POSTGRES_HOST").unwrap(), - var("POSTGRES_DBNAME").unwrap() + // var("POSTGRES_DBNAME").unwrap() ); PgPool::connect(&url).await } #[tokio::main] async fn main() { - let store: Arc> = Arc::new(RwLock::new(store::Store::new())); + let store: Arc> = Arc::new(RwLock::new(json_store::Store::new())); let ip: SocketAddr = SocketAddr::new([127, 0, 0, 1].into(), 3000); let listener: tokio::net::TcpListener = tokio::net::TcpListener::bind(ip).await.unwrap(); let apis = Router::new()