Skip to content

Commit 63479ef

Browse files
authored
Merge pull request #1 from Rafael24595/dev
[FEATURE] 0.1.0 release
2 parents e9b5e5a + 9b0dd03 commit 63479ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2292
-204
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
/.vscode
22
/target
3-
/docker
3+
/docker
4+
/assets

Cargo.lock

Lines changed: 136 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

8+
[profile.dev]
9+
opt-level = 3
10+
11+
[profile.release]
12+
opt-level = 3
13+
814
[dependencies]
915
tokio = { version = "1", features = ["full"] }
1016
lazy_static = "1.4.0"
@@ -16,4 +22,9 @@ serde_json = "1.0"
1622
crossterm = "0.27.0"
1723
uuid = "1.8.0"
1824
cargo_metadata = "0.18.1"
25+
base64-compat = "1.0.0"
26+
hmac = "0.12.1"
27+
sha2 = "0.10.8"
28+
jwt = "0.16.0"
29+
regex = "1.10.4"
1930
rust_db_manager_core = { git = "https://github.com/Rafael24595/rust-db-manager.git", branch = "dev" }

src/commons/configuration/web_configuration.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ pub struct WebConfiguration {
1717
}
1818

1919
impl WebConfiguration {
20+
21+
pub const COOKIE_NAME: &'static str = "DB_TOKEN";
2022

2123
pub fn initialize() -> WebConfiguration {
2224
let _ = Configuration::initialize();

src/commons/exception/api_exception.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ use std::error::Error;
33

44
use rust_db_manager_core::commons::exception::connect_exception::ConnectException;
55

6-
pub(crate) const EXCEPTION_HEADER: &str = "Error-Code";
7-
86
#[derive(Debug, Clone)]
97
pub struct ApiException {
108
status: u16,
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
use std::fmt;
2+
use std::error::Error;
3+
4+
use super::api_exception::ApiException;
5+
6+
#[derive(Debug, Clone)]
7+
pub struct AuthException {
8+
status: u16,
9+
message: String,
10+
reset: bool,
11+
}
12+
13+
impl fmt::Display for AuthException {
14+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
15+
write!(f, "AuthException: {}", self.message)
16+
}
17+
}
18+
19+
impl Error for AuthException {}
20+
21+
22+
impl AuthException {
23+
24+
pub fn from(status: u16, exception: ApiException, reset: bool) -> AuthException {
25+
AuthException {
26+
status: status,
27+
message: exception.message(),
28+
reset: reset
29+
}
30+
}
31+
32+
pub fn new(status: u16, message: String) -> AuthException {
33+
AuthException {
34+
status,
35+
message,
36+
reset: false
37+
}
38+
}
39+
40+
pub fn new_reset(status: u16, message: String) -> AuthException {
41+
AuthException {
42+
status,
43+
message,
44+
reset: true
45+
}
46+
}
47+
48+
pub fn status(&self) -> u16 {
49+
return self.status;
50+
}
51+
52+
pub fn message(&self) -> String {
53+
return self.message.clone();
54+
}
55+
56+
pub fn reset(&self) -> bool {
57+
return self.reset;
58+
}
59+
60+
}

src/domain/builder_db_connection_data.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
use rust_db_manager_core::{domain::connection_data::ConnectionData, infrastructure::repository::e_db_repository::EDBRepository};
22

3-
use crate::{commons::exception::api_exception::ApiException, infrastructure::dto::db_service::dto_db_connection_data::DTOConnectionData};
3+
use crate::{commons::exception::api_exception::ApiException, infrastructure::dto::service::generate::dto_db_connection_data::DTODBConnectionData};
44

55
pub struct BuilderConnectionData {
66
}
77

88
impl BuilderConnectionData {
99

10-
pub fn make(dto: DTOConnectionData) -> Result<ConnectionData, ApiException> {
11-
let category = EDBRepository::from_string(dto.category.clone());
10+
pub fn make(dto: DTODBConnectionData) -> Result<ConnectionData, ApiException> {
11+
let category = EDBRepository::from_string(&dto.category);
1212
if let None = category {
1313
let message = format!("Data base type '{}' not supported.", dto.category);
1414
return Err(ApiException::new(404, message));

src/domain/builder_db_service.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use rust_db_manager_core::infrastructure::db_service::DBService;
22

3-
use crate::{commons::exception::api_exception::ApiException, infrastructure::dto::db_service::dto_db_service::DTODBService};
3+
use crate::{commons::exception::api_exception::ApiException, infrastructure::dto::service::generate::dto_service_create_request::DTOServiceRequest};
44

55
use super::builder_db_connection_data::BuilderConnectionData;
66

@@ -9,10 +9,15 @@ pub struct BuilderDBService {
99

1010
impl BuilderDBService {
1111

12-
pub fn make(dto: DTODBService) -> Result<DBService, ApiException> {
12+
pub fn make(dto: DTOServiceRequest) -> Result<DBService, ApiException> {
1313
let connection_data = BuilderConnectionData::make(dto.connection_data)?;
14-
let service = DBService::new(dto.name, dto.owner, connection_data);
15-
Ok(service)
14+
15+
let service = DBService::new(dto.name, dto.owner, dto.protected, dto.password, connection_data);
16+
if service.is_err() {
17+
return Err(ApiException::from(500, service.err().unwrap()));
18+
}
19+
20+
Ok(service.unwrap())
1621
}
1722

1823
}

0 commit comments

Comments
 (0)