Skip to content

Commit a72b6ab

Browse files
committed
wip
1 parent 46a737f commit a72b6ab

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

src/database.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use sqlx::sqlite::{SqliteConnectOptions, SqlitePoolOptions};
1+
use sqlx::sqlite::{SqliteConnectOptions};
22
use sqlx::{ConnectOptions, Executor, SqlitePool};
33
use std::str::FromStr;
44

src/logic/account.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use crate::account::{BareAccount, EditAccount};
22
use crate::database;
33
use crate::logic::AuthContext;
4-
use axum::extract::State;
5-
64
use crate::logic::auth::logout;
5+
6+
use axum::extract::State;
77
use axum::response::IntoResponse;
88
use axum::Json;
99
use http::StatusCode;

src/logic/activities.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub async fn get_activity(
1717
) -> impl IntoResponse {
1818
let activity = match database::activity::get(pool, activity_id).await {
1919
Ok(activity) => activity,
20-
Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
20+
// Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
2121
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR).into_response(),
2222
};
2323

@@ -133,12 +133,12 @@ pub async fn edit_activity(
133133
State(pool): State<&SqlitePool>,
134134
mut auth: AuthContext,
135135
Path(activity_id): Path<(i64)>,
136-
Json(payload): Json<StringBareActivity>,
136+
Json(payload): Json<BareActivity>, // todo string bare activity
137137
) -> impl IntoResponse {
138138
// get the referenced activity from the database
139139
let activity = match database::activity::get(pool, activity_id).await {
140140
Ok(activity) => activity,
141-
Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
141+
// Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
142142
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR).into_response(),
143143
};
144144

@@ -168,7 +168,7 @@ pub async fn delete_activity(
168168
// get the referenced activity from the database
169169
let activity = match database::activity::get(pool, activity_id).await {
170170
Ok(activity) => activity,
171-
Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
171+
// Err(Error::ElementNotFound) => return (StatusCode::NOT_FOUND).into_response(),
172172
// todo catch additional errors
173173
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR).into_response(),
174174
};

src/logic/auth.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use crate::account::{Account, BareAccount};
22
use crate::database;
33
use crate::hasher;
4-
use axum::extract::State;
54

5+
use axum::extract::State;
66
use axum::http::StatusCode;
77
use axum::response::IntoResponse;
88
use axum::Json;

src/logic/users.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ use axum::response::IntoResponse;
55
use axum::Json;
66
use http::StatusCode;
77
use sqlx::SqlitePool;
8+
use crate::database::Error;
89

910
pub async fn get_user(
1011
State(pool): State<&SqlitePool>,
1112
Path(username): Path<String>,
1213
) -> impl IntoResponse {
1314
let user = match database::user::get(pool, &username).await {
1415
Ok(user) => user,
15-
Err(Error::ElementNotFound) => return (StatusCode::NO_CONTENT).into_response(),
16+
// Err(Error::ElementNotFound) => return (StatusCode::NO_CONTENT).into_response(),
1617
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR).into_response(),
1718
};
1819

@@ -25,7 +26,7 @@ pub async fn get_user_id(
2526
) -> impl IntoResponse {
2627
let user = match database::user::get_id(pool, user_id).await {
2728
Ok(user) => user,
28-
Err(Error::ElementNotFound) => return (StatusCode::NO_CONTENT).into_response(),
29+
// Err(Error::ElementNotFound) => return (StatusCode::NO_CONTENT).into_response(),
2930
Err(_) => return (StatusCode::INTERNAL_SERVER_ERROR).into_response(),
3031
};
3132

src/routes.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,7 @@ pub async fn backend_router(pool: &SqlitePool) -> Router {
3737
let session_layer = SessionLayer::new(session_store, &secret)
3838
.with_secure(false)
3939
.with_same_site_policy(SameSite::Lax);
40-
let pool = SqlitePoolOptions::new().connect(DB_URI).await.unwrap();
41-
let user_store = SqliteStore::<Account>::new(pool);
40+
let user_store = SqliteStore::<Account>::new(pool.clone());
4241
let auth_layer = AuthLayer::new(user_store, &secret);
4342

4443
let auth_router = Router::new()

0 commit comments

Comments
 (0)