-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from JKearnsl/jk-0411
update 0.1.1
- Loading branch information
Showing
19 changed files
with
235 additions
and
414 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "tobox" | ||
version = "0.1.0" | ||
version = "0.1.1" | ||
authors = ["JKearnsl <[email protected]>"] | ||
edition = "2021" | ||
|
||
|
@@ -42,4 +42,5 @@ sqlx = { version = "^0.7", features = [ | |
"sqlite", | ||
"sqlx-sqlite", | ||
"chrono" | ||
] } | ||
] } | ||
regex = "1.10.5" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use strum_macros::{Display, EnumString}; | ||
use uuid::Uuid; | ||
|
||
|
||
pub type BoxId = Uuid; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct Box { | ||
pub id: BoxId, | ||
pub name: String, | ||
pub created_at: DateTime<Utc> | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,5 @@ pub mod r#box; | |
pub mod object; | ||
pub mod user; | ||
pub mod permission; | ||
pub mod role; | ||
pub mod role; | ||
pub mod token_pair; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use crate::domain::models::user::UserId; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct TokenPair { | ||
pub public: String, | ||
pub enc_private: String, | ||
pub user_id: UserId | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,13 @@ | ||
use chrono::{DateTime, Utc}; | ||
use serde::{Deserialize, Serialize}; | ||
use strum_macros::{Display, EnumString}; | ||
use uuid::Uuid; | ||
|
||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, EnumString, Display)] | ||
#[serde(rename_all = "lowercase")] | ||
#[strum(serialize_all = "lowercase")] | ||
pub enum UserState { | ||
Active, | ||
Inactive, | ||
Banned, | ||
Deleted, | ||
} | ||
|
||
pub type UserId = Uuid; | ||
|
||
#[derive(Clone, Debug, Serialize, Deserialize)] | ||
pub struct User { | ||
pub id: UserId, | ||
pub username: String, | ||
pub email: String, | ||
pub first_name: Option<String>, | ||
pub last_name: Option<String>, | ||
pub state: UserState, | ||
pub hashed_password: String, | ||
pub created_at: DateTime<Utc>, | ||
pub updated_at: Option<DateTime<Utc>>, | ||
} | ||
pub created_at: DateTime<Utc> | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
use chrono::Utc; | ||
use uuid::Uuid; | ||
|
||
use crate::domain::models::r#box::Box; | ||
|
||
pub struct BoxService { } | ||
|
||
impl BoxService { | ||
|
||
pub fn create_box(&self, name: String) -> Box { | ||
Box { | ||
id: Uuid::new_v4(), | ||
name, | ||
created_at: Utc::now(), | ||
} | ||
} | ||
|
||
pub fn update_box(&self, r#box: Box, new_name: String) -> Box { | ||
Box { | ||
name: new_name, | ||
..r#box | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
pub mod access; | ||
pub mod user; | ||
pub mod validator; | ||
pub mod session; | ||
pub mod token_pair; | ||
pub mod role; | ||
pub mod access_log; | ||
pub mod permission; | ||
pub mod external; | ||
pub mod r#box; | ||
pub mod object; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use std::collections::HashMap; | ||
use chrono::Utc; | ||
use uuid::Uuid; | ||
|
||
use crate::domain::models::object::Object; | ||
|
||
pub struct ObjectService { } | ||
|
||
impl ObjectService { | ||
|
||
pub fn create_box( | ||
&self, | ||
name: String, | ||
path: String, | ||
hash: String, | ||
size: u64, | ||
content_type: String, | ||
metadata: HashMap<String, String>, | ||
) -> Object { | ||
Object { | ||
id: Uuid::new_v4(), | ||
name, | ||
path, | ||
hash, | ||
size, | ||
content_type, | ||
metadata, | ||
created_at: Utc::now(), | ||
updated_at: None, | ||
} | ||
} | ||
|
||
pub fn update_box( | ||
&self, | ||
object: Object, | ||
new_name: String, | ||
new_path: String, | ||
new_metadata: HashMap<String, String>, | ||
) -> Object { | ||
Object { | ||
name: new_name, | ||
path: new_path, | ||
metadata: new_metadata, | ||
updated_at: Some(Utc::now()), | ||
..object | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.