@smbcloud / cli / commits / 3dfa730

Use debug assertion

Seto Elkahfi committed Feb 19, 2023 at 11:07 UTC 3dfa73085905ac567e08803776b71c93708d37c0
3 files changed +10 -2
src/constants.rs
+6 -1
@@ -1,4 +1,9 @@
1 use console::Emoji;
2 -pub const BASE_URL: &str = "http://localhost:3000";
2 +
3 +#[cfg(debug_assertions)]
4 +pub const BASE_URL: &'static str = "http://localhost:3000";
5 +
6 +#[cfg(not(debug_assertions))]
7 +pub const BASE_URL: &'static str = "https://api.smbpndk.io/";
8
9 pub const GUARD_EMOJI: Emoji<'_, '_> = Emoji("🛡 ", "");
src/lib.rs
+1
@@ -1,2 +1,3 @@
1 pub mod cli;
2 +pub mod constants;
3 pub mod login;
src/login/process.rs
+3 -1
@@ -2,6 +2,8 @@ use anyhow::Result;
2 use reqwest::Client;
3 use serde::{Deserialize, Serialize};
4
5 +use crate::constants::BASE_URL;
6 +
7 pub struct LoginArgs {
8 pub username: String,
9 pub password: String,
@@ -33,7 +35,7 @@ pub async fn process_login(args: LoginArgs) -> Result<()> {
35 };
36
37 let response: LoginResult = Client::new()
36 - .post("http://localhost:3000/v1/users/sign_in")
38 + .post([BASE_URL, "/v1/users/sign_in"].join(""))
39 .json(&login_params)
40 .send()
41 .await?