mirror of
https://github.com/MedzikUser/HomeDisk.git
synced 2024-08-14 21:46:53 +00:00
chore: cleanup
This commit is contained in:
parent
b41ec426e6
commit
75f523f116
4 changed files with 13 additions and 14 deletions
|
@ -13,7 +13,7 @@ use super::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// SQLite database
|
/// SQLite database
|
||||||
#[derive(Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Database {
|
pub struct Database {
|
||||||
/// Sqlite connection pool
|
/// Sqlite connection pool
|
||||||
pub pool: SqlitePool,
|
pub pool: SqlitePool,
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use crypto_utils::sha::{Algorithm, CryptographicHash};
|
use crypto_utils::sha::{Algorithm, CryptographicHash};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Serialize;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
/// SQL user entry
|
/// SQL user entry
|
||||||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize)]
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub id: String,
|
pub id: String,
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
|
|
@ -2,9 +2,9 @@ use serde::Serialize;
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Error)]
|
#[derive(Debug, Error)]
|
||||||
pub enum Error {
|
pub enum Error {
|
||||||
// auth error
|
// `/auth` error
|
||||||
#[error("Too many request, please slow down.")]
|
#[error("Too many request, please slow down.")]
|
||||||
RateLimit,
|
RateLimit,
|
||||||
#[error("User not found")]
|
#[error("User not found")]
|
||||||
|
@ -27,7 +27,8 @@ pub enum Error {
|
||||||
MissingHeader(&'static str),
|
MissingHeader(&'static str),
|
||||||
#[error("`Authorization` header must be a bearer token")]
|
#[error("`Authorization` header must be a bearer token")]
|
||||||
MissingBearer,
|
MissingBearer,
|
||||||
// fs error
|
|
||||||
|
// `/fs` error
|
||||||
#[error("Invalid `path` query parameter")]
|
#[error("Invalid `path` query parameter")]
|
||||||
InvalidPath,
|
InvalidPath,
|
||||||
#[error("Failed to read files from directory")]
|
#[error("Failed to read files from directory")]
|
||||||
|
@ -46,7 +47,7 @@ pub enum Error {
|
||||||
DeleteFile,
|
DeleteFile,
|
||||||
#[error("Multipart error")]
|
#[error("Multipart error")]
|
||||||
Multipart,
|
Multipart,
|
||||||
#[error("Write to file failed")]
|
#[error("Failed write to file")]
|
||||||
WriteFile,
|
WriteFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
//! [Configuration file types](Config)
|
|
||||||
|
|
||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::Deserialize;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
pub http: ConfigHTTP,
|
pub http: ConfigHTTP,
|
||||||
pub jwt: ConfigJWT,
|
pub jwt: ConfigJWT,
|
||||||
pub storage: ConfigStorage,
|
pub storage: ConfigStorage,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
#[serde(rename_all = "camelCase")]
|
#[serde(rename_all = "camelCase")]
|
||||||
pub struct ConfigHTTP {
|
pub struct ConfigHTTP {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
|
@ -22,13 +20,13 @@ pub struct ConfigHTTP {
|
||||||
pub tls_key: String,
|
pub tls_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct ConfigJWT {
|
pub struct ConfigJWT {
|
||||||
pub secret: String,
|
pub secret: String,
|
||||||
pub expires: i64,
|
pub expires: i64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Deserialize)]
|
||||||
pub struct ConfigStorage {
|
pub struct ConfigStorage {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue