11 files changed
+20
-29
smbpndk-cli/src/account/forgot/mod.rs
+2
-4
@@ -3,12 +3,10 @@ use console::style;
3
use dialoguer::{theme::ColorfulTheme, Input, Password};
4
use reqwest::{Client, StatusCode};
5
use serde::{Deserialize, Serialize};
6
+use smbpndk_networking::constants::BASE_URL;
7
use spinners::Spinner;
8
8
-use crate::{
9
- constants::BASE_URL,
10
- util::{email_validation, CommandResult},
11
-};
9
+use crate::util::{email_validation, CommandResult};
10
11
#[derive(Debug, Serialize)]
12
struct Args {
smbpndk-cli/src/account/login/process.rs
+1
-1
@@ -8,11 +8,11 @@ use console::style;
8
use dialoguer::{theme::ColorfulTheme, Input, Password};
9
use reqwest::Client;
10
use serde::{Deserialize, Serialize};
11
+use smbpndk_networking::constants::BASE_URL;
12
use spinners::Spinner;
13
14
use crate::{
15
account::model::{Data, Status, User},
15
- constants::BASE_URL,
16
debug,
17
util::CommandResult,
18
};
smbpndk-cli/src/account/signup/process.rs
+1
-1
@@ -12,12 +12,12 @@ use dialoguer::{theme::ColorfulTheme, Input, Password, Select};
12
use regex::Regex;
13
use reqwest::{Client, StatusCode};
14
use serde::{Deserialize, Serialize};
15
+use smbpndk_networking::constants::BASE_URL;
16
use spinners::Spinner;
17
use url_builder::URLBuilder;
18
19
use crate::{
20
account::model::{Data, Status, User},
20
- constants::BASE_URL,
21
debug,
22
util::CommandResult,
23
};
smbpndk-cli/src/auth_app/mod.rs
+2
-2
@@ -78,8 +78,8 @@ pub async fn process_auth_app(commands: Commands) -> Result<CommandResult> {
78
println!("Error: {e:#?}");
79
Ok(CommandResult {
80
spinner,
81
- symbol: "❌".to_owned(),
82
- msg: "Failed to get all projects.".to_owned(),
81
+ symbol: "😩".to_owned(),
82
+ msg: "Failed to get all auth apps.".to_owned(),
83
})
84
}
85
}
smbpndk-cli/src/constants.rs
deleted
-10
@@ -1,10 +0,0 @@
1
-use console::Emoji;
2
-
3
-#[cfg(debug_assertions)]
4
-pub const BASE_URL: &str = "http://localhost:3000";
5
-
6
-#[cfg(not(debug_assertions))]
7
-pub const BASE_URL: &str = "https://api.smbpndk.com";
8
-
9
-pub const OK_EMOJI: Emoji<'_, '_> = Emoji("✅ ", "");
10
-pub const ERROR_EMOJI: Emoji<'_, '_> = Emoji("❌ ", "");
smbpndk-cli/src/lib.rs
-1
@@ -1,6 +1,5 @@
1
pub mod account;
2
pub mod auth_app;
3
pub mod cli;
4
-pub mod constants;
4
pub mod projects;
5
pub mod util;
smbpndk-cli/src/projects/crud/mod.rs
+6
-3
@@ -1,17 +1,20 @@
1
-use crate::{constants::BASE_URL, debug};
1
+use crate::debug;
2
use anyhow::{anyhow, Result};
3
use reqwest::Client;
4
5
use smbpndk_model::{Project, ProjectCreate};
6
-use smbpndk_networking::get_token;
6
+use smbpndk_networking::{constants::BASE_URL, get_token};
7
8
pub async fn get_all() -> Result<Vec<Project>> {
9
// Get current token
10
- let token = get_token().await.unwrap();
10
+ let token = get_token().await?;
11
+
12
+ print!("{}", token);
13
14
let response = Client::new()
15
.get([BASE_URL, "v1/projects"].join(""))
16
.header("Authorization", token)
17
+ .header("User-agent", "smbpndk-cli")
18
.send()
19
.await?;
20
smbpndk-cli/src/projects/mod.rs
+1
-1
@@ -110,7 +110,7 @@ pub async fn process_projects(commands: Commands) -> Result<CommandResult> {
110
println!("Error: {e:#?}");
111
Ok(CommandResult {
112
spinner,
113
- symbol: "❌".to_owned(),
113
+ symbol: "😩".to_owned(),
114
msg: "Failed to get all projects.".to_owned(),
115
})
116
}
smbpndk-model/src/lib.rs
+2
-1
@@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize};
2
3
#[derive(Serialize, Deserialize, Debug)]
4
pub struct AuthApp {
5
- pub id: i32,
5
+ pub id: String,
6
+ pub secret: String,
7
pub name: String,
8
pub created_at: String,
9
pub updated_at: String,
smbpndk-networking/src/constants.rs
+2
-2
@@ -1,5 +1,5 @@
1
#[cfg(debug_assertions)]
2
-pub const BASE_URL: &str = "http://localhost:3000";
2
+pub const BASE_URL: &str = "http://localhost:3000/";
3
4
#[cfg(not(debug_assertions))]
5
-pub const BASE_URL: &str = "https://api.smbpndk.com";
5
+pub const BASE_URL: &str = "https://api.smbpndk.com/";
smbpndk-networking/src/lib.rs
+3
-3
@@ -1,4 +1,4 @@
1
-mod constants;
1
+pub mod constants;
2
3
use anyhow::{anyhow, Result};
4
use constants::BASE_URL;
@@ -20,7 +20,7 @@ pub async fn get_token() -> Result<String> {
20
21
pub async fn get_auth_apps() -> Result<Vec<AuthApp>> {
22
// Get current token
23
- let token = get_token().await.unwrap();
23
+ let token = get_token().await?;
24
25
let response = Client::new()
26
.get([BASE_URL, "v1/auth_apps"].join(""))
@@ -39,7 +39,7 @@ pub async fn get_auth_apps() -> Result<Vec<AuthApp>> {
39
40
pub async fn get_auth_app(id: String) -> Result<AuthApp> {
41
// Get current token
42
- let token = get_token().await.unwrap();
42
+ let token = get_token().await?;
43
44
let response = Client::new()
45
.get([BASE_URL, "v1/auth_apps/", &id].join(""))