chore: cleanup

This commit is contained in:
MedzikUser 2022-09-20 20:02:45 +02:00
parent b41ec426e6
commit 75f523f116
No known key found for this signature in database
GPG Key ID: A5FAC1E185C112DB
4 changed files with 13 additions and 14 deletions

View File

@ -13,7 +13,7 @@ use super::{
};
/// SQLite database
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Database {
/// Sqlite connection pool
pub pool: SqlitePool,

View File

@ -1,9 +1,9 @@
use crypto_utils::sha::{Algorithm, CryptographicHash};
use serde::{Deserialize, Serialize};
use serde::Serialize;
use uuid::Uuid;
/// SQL user entry
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Serialize)]
pub struct User {
pub id: String,
pub username: String,

View File

@ -2,9 +2,9 @@ use serde::Serialize;
use thiserror::Error;
use tracing::error;
#[derive(Debug, Clone, Error)]
#[derive(Debug, Error)]
pub enum Error {
// auth error
// `/auth` error
#[error("Too many request, please slow down.")]
RateLimit,
#[error("User not found")]
@ -27,7 +27,8 @@ pub enum Error {
MissingHeader(&'static str),
#[error("`Authorization` header must be a bearer token")]
MissingBearer,
// fs error
// `/fs` error
#[error("Invalid `path` query parameter")]
InvalidPath,
#[error("Failed to read files from directory")]
@ -46,7 +47,7 @@ pub enum Error {
DeleteFile,
#[error("Multipart error")]
Multipart,
#[error("Write to file failed")]
#[error("Failed write to file")]
WriteFile,
}

View File

@ -1,17 +1,15 @@
//! [Configuration file types](Config)
use std::fs;
use serde::{Deserialize, Serialize};
use serde::Deserialize;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
pub struct Config {
pub http: ConfigHTTP,
pub jwt: ConfigJWT,
pub storage: ConfigStorage,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ConfigHTTP {
pub host: String,
@ -22,13 +20,13 @@ pub struct ConfigHTTP {
pub tls_key: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
pub struct ConfigJWT {
pub secret: String,
pub expires: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[derive(Debug, Clone, Deserialize)]
pub struct ConfigStorage {
pub path: String,
}