🔨 Refactors code
This commit is contained in:
@@ -15,7 +15,7 @@ use uuid::Uuid;
|
|||||||
pub fn index(
|
pub fn index(
|
||||||
offset: Option<i64>,
|
offset: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
auth: Authenticated,
|
_auth: Authenticated,
|
||||||
state: &State<AppState>,
|
state: &State<AppState>,
|
||||||
) -> Result<Json<Vec<HitDTO>>, Status> {
|
) -> Result<Json<Vec<HitDTO>>, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
@@ -37,7 +37,7 @@ pub fn index(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[get("/<id>")]
|
#[get("/<id>")]
|
||||||
pub fn get(id: &str, auth: Authenticated, state: &State<AppState>) -> Result<Json<HitDTO>, Status> {
|
pub fn get(id: &str, _auth: Authenticated, state: &State<AppState>) -> Result<Json<HitDTO>, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
|
|
||||||
let id = match Uuid::parse_str(id).ok() {
|
let id = match Uuid::parse_str(id).ok() {
|
||||||
@@ -57,7 +57,7 @@ pub fn get(id: &str, auth: Authenticated, state: &State<AppState>) -> Result<Jso
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[delete("/<id>")]
|
#[delete("/<id>")]
|
||||||
pub fn delete(id: &str, auth: Authenticated, state: &State<AppState>) -> Result<Status, Status> {
|
pub fn delete(id: &str, _auth: Authenticated, state: &State<AppState>) -> Result<Status, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
|
|
||||||
let id = match Uuid::parse_str(id).ok() {
|
let id = match Uuid::parse_str(id).ok() {
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use uuid::Uuid;
|
|||||||
pub fn index(
|
pub fn index(
|
||||||
offset: Option<i64>,
|
offset: Option<i64>,
|
||||||
limit: Option<i64>,
|
limit: Option<i64>,
|
||||||
auth: Authenticated,
|
_auth: Authenticated,
|
||||||
state: &State<AppState>,
|
state: &State<AppState>,
|
||||||
) -> Result<Json<Vec<TrackerDTO>>, Status> {
|
) -> Result<Json<Vec<TrackerDTO>>, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
@@ -40,7 +40,7 @@ pub fn index(
|
|||||||
#[get("/<id>")]
|
#[get("/<id>")]
|
||||||
pub fn get(
|
pub fn get(
|
||||||
id: &str,
|
id: &str,
|
||||||
auth: Authenticated,
|
_auth: Authenticated,
|
||||||
state: &State<AppState>,
|
state: &State<AppState>,
|
||||||
) -> Result<Json<TrackerDTO>, Status> {
|
) -> Result<Json<TrackerDTO>, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
@@ -62,7 +62,7 @@ pub fn get(
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[post("/")]
|
#[post("/")]
|
||||||
pub fn create(auth: Authenticated, state: &State<AppState>) -> Result<Json<TrackerDTO>, Status> {
|
pub fn create(_auth: Authenticated, state: &State<AppState>) -> Result<Json<TrackerDTO>, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
|
|
||||||
let new = Tracker {
|
let new = Tracker {
|
||||||
@@ -85,7 +85,7 @@ pub fn create(auth: Authenticated, state: &State<AppState>) -> Result<Json<Track
|
|||||||
pub fn delete(
|
pub fn delete(
|
||||||
id: &str,
|
id: &str,
|
||||||
delete_hits: Option<bool>,
|
delete_hits: Option<bool>,
|
||||||
auth: Authenticated,
|
_auth: Authenticated,
|
||||||
state: &State<AppState>,
|
state: &State<AppState>,
|
||||||
) -> Result<Status, Status> {
|
) -> Result<Status, Status> {
|
||||||
let mut db = state.db.lock().unwrap();
|
let mut db = state.db.lock().unwrap();
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
mod api;
|
mod api;
|
||||||
|
mod auth;
|
||||||
mod dtos;
|
mod dtos;
|
||||||
mod models;
|
mod models;
|
||||||
mod schema;
|
mod schema;
|
||||||
mod auth;
|
|
||||||
|
|
||||||
use crate::api::hit;
|
use crate::api::hit;
|
||||||
use crate::api::image;
|
use crate::api::image;
|
||||||
|
|||||||
@@ -13,4 +13,3 @@ pub struct Hit {
|
|||||||
pub language: Option<String>,
|
pub language: Option<String>,
|
||||||
pub created_at: NaiveDateTime,
|
pub created_at: NaiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user