rename store to json store

This commit is contained in:
David Westgate 2024-05-27 13:00:13 -07:00
parent 2d05b0be07
commit d64580df0e
3 changed files with 6 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/// All API route handlers of the application /// 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::*; use crate::*;
const DEFAULT_PAGE: usize = 0; const DEFAULT_PAGE: usize = 0;
const DEFAULT_PAGE_SIZE: usize = 10; const DEFAULT_PAGE_SIZE: usize = 10;

View File

@ -1,7 +1,7 @@
mod answer; mod answer;
mod api; mod api;
mod question; mod question;
mod store; mod json_store;
use axum::{ use axum::{
extract::{Path, Query, State}, extract::{Path, Query, State},
http::{StatusCode, Uri}, http::{StatusCode, Uri},
@ -24,7 +24,7 @@ use std::{
path::PathBuf, path::PathBuf,
sync::Arc, sync::Arc,
}; };
use store::Store; use json_store::Store;
use tokio::sync::RwLock; use tokio::sync::RwLock;
// generic handler for any not supported route/method combination // 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<Pool<Postgres>, sqlx::Error> { async fn db_connection() -> Result<Pool<Postgres>, sqlx::Error> {
let url: String = format!( let url: String = format!(
"postgres://{}:{}@{}:5432/{}", "postgres://{}:{}@{}:5432"/*{}*/,
var("POSTGRES_USER").unwrap(), var("POSTGRES_USER").unwrap(),
var("POSTGRES_PASSWORD").unwrap(), var("POSTGRES_PASSWORD").unwrap(),
var("POSTGRES_HOST").unwrap(), var("POSTGRES_HOST").unwrap(),
var("POSTGRES_DBNAME").unwrap() // var("POSTGRES_DBNAME").unwrap()
); );
PgPool::connect(&url).await PgPool::connect(&url).await
} }
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
let store: Arc<RwLock<Store>> = Arc::new(RwLock::new(store::Store::new())); let store: Arc<RwLock<Store>> = Arc::new(RwLock::new(json_store::Store::new()));
let ip: SocketAddr = SocketAddr::new([127, 0, 0, 1].into(), 3000); let ip: SocketAddr = SocketAddr::new([127, 0, 0, 1].into(), 3000);
let listener: tokio::net::TcpListener = tokio::net::TcpListener::bind(ip).await.unwrap(); let listener: tokio::net::TcpListener = tokio::net::TcpListener::bind(ip).await.unwrap();
let apis = Router::new() let apis = Router::new()