2024
Resend
We should be building out these API endpoints a bit faster but I got side tracked with the Steam integration! Solo leveling through these projects can be a bit of a pain.
Okay! So let us look at the package structure for kbve:
Under entity
, we will add a client folder + mod, then start building out the resend.rs
.
This resend API will be rewritten later on but for now we just need the basics of it out of the way!
Going back to the RecoverUserSchema
, we want to add a quick sanitize method, to clean the variables that are added into the Schema.
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct RecoverUserSchema {
pub email: String,
pub service: String,
pub captcha: String,
}
impl RecoverUserSchema {
pub fn sanitize(&mut self) -> Result<(), String> {
// Sanitize Email
let limited_email = crate::utility::sanitize_string_limit(&self.email);
match crate::utility::sanitize_email(&limited_email) {
Ok(clean_email) => {
self.email = clean_email;
}
Err(e) => {
return Err(e.to_string());
}
}
// Sanitize Service String
// Santize Captcha Token
Ok(())
}
}
We can use the sanitize_string_limit
and sanitize_email
functions to help us clean up the email.
Afterwards we have two more strings to clean up, the service should be easy, so we will just clean that using the string limit.
Actually this would be a great time to test out the ValidationBuilder
and move the sanitization into that area!
We already have a sanitization for the email built into the validationbuilder, so we can skip that part BUT we will need to build two new regexs for the service
and captcha
.
For future references, services would only be 3 to 32 characters and alphanumeric, so here is the regex that we can add into the regex_extractor
.
pub static SANITIZATION_SERVICE_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"^[a-zA-Z0-9]{3,32}$").unwrap()
});
pub fn extract_service_from_regex(service: &str) -> Result<String, &'static str> {
if SANITIZATION_SERVICE_REGEX.is_match(service) {
Ok(service.to_string())
} else {
Err("Invalid service format")
}
}
Then we add the extract_service_from_regex
into the functions that we will call within our validation builder.
Okay this will help with the service cleaning, then there is the captcha token cleaning that we need to do next.
pub static VALIDATION_TOKEN_REGEX: Lazy<Regex> = Lazy::new(|| {
Regex::new(r"^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$").unwrap()
});
pub fn extract_captcha_token_from_regex(token: &str) -> Result<String, &'static str> {
if VALIDATION_TOKEN_REGEX.is_match(token) {
Ok(token.to_string())
} else {
Err("Invalid token format")
}
}
The only thing we want to do here is be a bit more specific with the tokens. Okay, these look great! Lets go ahead and add them back into the validationbuilder.
use crate::utils::sanitization::{
extract_email_from_regex,
extract_github_username_from_regex,
extract_instagram_username_from_regex,
extract_unsplash_photo_id_from_regex,
extract_discord_server_id_from_regex,
extract_ulid_from_regex,
extract_username_from_regex,
extract_service_from_regex,
extract_captcha_token_from_regex,
};
After importing them, we need to add them into the rules for calling them within the validationbuilder.
Let us run a quick dry run with our changes, there is probably a couple errors that we need to account for.
cargo publish -p kbve --dry-run --allow-dirty
Okay! I just realized I made a mistake and that the validation builder was moved to the jedi
For this situation, we will just move the changes we made to the OG validation builder into the jedi
package.
In this case, we will be using this shell command to check:
cargo publish -p jedi --dry-run --allow-dirty
Okay! Both packages are building, so I will go ahead and move those up a branch!
We do need the jedi
package to build and release, then go back and fix our sanitization function.
2023
- 9:30am - Dropping by the local Lenskart and asking my uncle to make two quick pair of aviator glasses for @sean and @ziggy9263. I have given this shop close to 20 pairs so far, I am definitely their customer of the month, may even become their customer of the year.
- 11:00am - Final visit the dentist to get some quick teeth cleaning! Through all of this, it seems that our dear friend, Fudster put me onto a quick quest. It is always interesting to be drugged up by a dentist and then open a bunch of unix terminals to setup a virtual machine. I enjoyed being in the dentist chair, half baked, typing away linux commands. If this was in the US, I am pretty sure the dentist would have violated several ethical boundaries for what I was doing haha.
- 12:30pm - Going to look over the current backend setup and see what needs to be updated. Overall the system looks healthy with no massive errors in any area. The main operating systems are still up to date, I looked over the unattended update logs and everything seems fine on that end.
- 5:00pm - Looking at tiles for remodeling the home and bathroom in India! It was interesting to see that electronic upgrades are more costly than doing general service to the house. I suppose it makes sense because labor costs in India are extremely cheap, as there is a large pool of workers. Yet the tech market within India is extremely inflated and it comes mainly from the excessive tariffs that are imposed on imports.
- 7:00pm - I think its time for me start researching into VCs/Venture again, just going to do some core / basic data gathering. I realized that I could add up to a million contacts onto the HubSpot CRM, so I am going to go through my older emails and reach out to some VC funds and build up an initial cold list. There are two main issues within the VC field that I am seeing, the first is the insane amount of capital going into machine learning / A.I-based startups and the second issue is that the rising interest rates is squeezing and limiting the general funds that they are willing to risk / invest. In addition to the rising rates, the recent bank collapses have also decreased the amount of risk that funds are willing to take.
- 7:30pm - Going to start a developer environment with a new hybrid cloud setup. I was looking at some of the recent changes with vCluster and I think its right about the best time to do a couple edge test cases from scratch. There will be two phases for this, the first will be doing everything manually and keeping track of the scripts, configurations, ect.. and the second phase will be to use Ansible-Tower to automate the deployment of the whole setup. I do not expect any of this to be successful but I am down to see where I hit failure, last time it was with the storage.
Quote
Courage is what it takes to stand up and speak; courage is also what it takes to sit down and listen. — Winston Churchill
Tasks
- Finalize materials for the house.
- Migrate rupees from bank balance to fix deposits.