feat(projects): added projects backend, todo add blogs
This commit is contained in:
@ -1,228 +0,0 @@
|
||||
---
|
||||
- tech_name: Rust
|
||||
tech_logo: https://www.svgrepo.com/show/374056/rust.svg
|
||||
project_site: https://www.rust-lang.org
|
||||
skill_level: 65
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: Python
|
||||
tech_logo: https://www.svgrepo.com/show/452091/python.svg
|
||||
project_site: https://www.python.org
|
||||
skill_level: 50
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: YAML
|
||||
tech_logo: https://yaml.org/favicon.svg
|
||||
project_site: https://yaml.org
|
||||
skill_level: 95
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: HTML5
|
||||
tech_logo: https://www.svgrepo.com/show/452228/html-5.svg
|
||||
project_site: https://google.com
|
||||
skill_level: 90
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: CSS
|
||||
tech_logo: https://www.svgrepo.com/show/452185/css-3.svg
|
||||
project_site: https://google.com
|
||||
skill_level: 65
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: JavaScript
|
||||
tech_logo: https://www.svgrepo.com/show/303206/javascript-logo.svg
|
||||
project_site: https://www.python.org
|
||||
skill_level: 50
|
||||
tech_cat:
|
||||
- Languages
|
||||
- tech_name: Markdown
|
||||
tech_logo: https://www.svgrepo.com/show/510065/markdown.svg
|
||||
project_site: https://www.markdownguide.org
|
||||
skill_level: 90
|
||||
tech_cat:
|
||||
- Languages
|
||||
|
||||
- tech_name: Actix
|
||||
tech_logo: https://actix.rs/img/logo.png
|
||||
project_site: https://actix.rs
|
||||
skill_level: 20
|
||||
tech_cat:
|
||||
- Backend
|
||||
- tech_name: FastAPI
|
||||
tech_logo: https://fastapi.tiangolo.com/img/favicon.png
|
||||
project_site: https://fastapi.tiangolo.com
|
||||
skill_level: 80
|
||||
tech_cat:
|
||||
- Backend
|
||||
- tech_name: Dioxus
|
||||
tech_logo: https://dioxuslabs.com/assets/smalllogo-b1926fd214dc8427.png
|
||||
project_site: https://dioxuslabs.com
|
||||
skill_level: 70
|
||||
tech_cat:
|
||||
- Backend
|
||||
- Frontend
|
||||
- tech_name: Diesel
|
||||
tech_logo: https://res.cloudinary.com/dpgrgsh7g/image/upload/v1745443276/diesel_logo_ujtvia.png
|
||||
project_site: https://diesel.rs
|
||||
skill_level: 10
|
||||
tech_cat:
|
||||
- Backend
|
||||
|
||||
- tech_name: React
|
||||
tech_logo: https://www.svgrepo.com/show/452092/react.svg
|
||||
project_site: https://react.dev
|
||||
skill_level: 70
|
||||
tech_cat:
|
||||
- Frontend
|
||||
- tech_name: Nextjs
|
||||
tech_logo: https://nextjs.org/favicon.ico
|
||||
project_site: https://nextjs.org
|
||||
skill_level: 10
|
||||
- Frontend
|
||||
- tech_name: Sqlite
|
||||
tech_logo: https://www.svgrepo.com/show/374094/sqlite.svg
|
||||
project_site: https://www.sqlite.org
|
||||
skill_level: 10
|
||||
tech_cat:
|
||||
- Databases
|
||||
- tech_name: PostgreSQL
|
||||
tech_logo: https://www.svgrepo.com/show/303301/postgresql-logo.svg
|
||||
project_site: https://www.postgresql.org
|
||||
skill_level: 10
|
||||
tech_cat:
|
||||
- Databases
|
||||
- tech_name: Mongodb
|
||||
tech_logo: https://www.svgrepo.com/show/331488/mongodb.svg
|
||||
project_site: https://www.mongodb.com
|
||||
skill_level: 10
|
||||
tech_cat:
|
||||
- Databases
|
||||
- tech_name: DynamoDB
|
||||
tech_logo: https://www.svgrepo.com/show/473526/amazondynamodb.svg
|
||||
project_site: https://aws.amazon.com/dynamodb/
|
||||
skill_level: 70
|
||||
tech_cat:
|
||||
- Databases
|
||||
|
||||
- tech_name: AWS
|
||||
tech_logo: https://www.svgrepo.com/show/448266/aws.svg
|
||||
project_site: https://aws.amazon.com
|
||||
skill_level: 30
|
||||
tech_cat:
|
||||
- Platforms
|
||||
- tech_name: Cloudflare
|
||||
tech_logo: https://qualified-production.s3.us-east-1.amazonaws.com/uploads/3b522ef84c409e4457032e4b4e3b984abbc92522c6f100f4ccc55c0ccfd3062b.png
|
||||
project_site: https://www.cloudflare.com/en-ca/
|
||||
skill_level: 65
|
||||
tech_cat:
|
||||
- Platforms
|
||||
- tech_name: Vercel
|
||||
tech_logo: https://www.svgrepo.com/show/361653/vercel-logo.svg
|
||||
project_site: https://vercel.com/home
|
||||
skill_level: 60
|
||||
tech_cat:
|
||||
- Platforms
|
||||
- tech_name: Netlify
|
||||
tech_logo: https://qualified-production.s3.us-east-1.amazonaws.com/uploads/0f63ae7280d8d193e346973a1915bf99aea8c63e254eb062bad0bde99b43a9b7.png
|
||||
project_site: https://www.netlify.com
|
||||
skill_level: 60
|
||||
tech_cat:
|
||||
- Platforms
|
||||
- tech_name: Gitea
|
||||
tech_logo: https://about.gitea.com/gitea.png
|
||||
project_site: https://about.gitea.com
|
||||
skill_level: 85
|
||||
tech_cat:
|
||||
- Platforms
|
||||
- tech_name: Github
|
||||
tech_logo: https://www.svgrepo.com/show/512317/github-142.svg
|
||||
project_site: https://github.com/darkicewolf50
|
||||
skill_level: 80
|
||||
tech_cat:
|
||||
- Platforms
|
||||
|
||||
- tech_name: Vs Code
|
||||
tech_logo: https://www.svgrepo.com/show/452129/vs-code.svg
|
||||
project_site: https://code.visualstudio.com
|
||||
skill_level: 60
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Git
|
||||
tech_logo: https://www.svgrepo.com/show/452210/git.svg
|
||||
project_site: https://git-scm.com
|
||||
skill_level: 55
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Prettier
|
||||
tech_logo: https://prettier.io/icon.png
|
||||
project_site: https://prettier.io
|
||||
skill_level: 90
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Firefox
|
||||
tech_logo: https://www.svgrepo.com/show/378808/firefox-developer-edition-57-70.svg
|
||||
project_site: https://www.mozilla.org/en-CA/firefox/developer/
|
||||
skill_level: 80
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Github Actions
|
||||
tech_logo: https://cdn.simpleicons.org/githubactions/2088FF
|
||||
project_site: https://github.com/
|
||||
skill_level: 50
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Traefik
|
||||
tech_logo: https://hub.docker.com/api/media/repos_logo/v1/library%2Ftraefik
|
||||
project_site: https://traefik.io/traefik/
|
||||
skill_level: 60
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Docker
|
||||
tech_logo: https://www.svgrepo.com/show/448221/docker.svg
|
||||
project_site: https://www.docker.com
|
||||
skill_level: 70
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Kubernetes
|
||||
tech_logo: https://kubernetes.io/images/kubernetes.png
|
||||
project_site: https://kubernetes.io
|
||||
skill_level: 5
|
||||
tech_cat:
|
||||
- Tools
|
||||
- tech_name: Terraform
|
||||
tech_logo: https://www.svgrepo.com/show/448253/terraform.svg
|
||||
project_site: https://www.terraform.io
|
||||
skill_level: 15
|
||||
tech_cat:
|
||||
- Tools
|
||||
|
||||
- tech_name: Email
|
||||
tech_logo: https://www.svgrepo.com/show/491226/email.svg
|
||||
project_site: mailto:darkicewolf50@gmail.com
|
||||
skill_level: 100
|
||||
tech_cat:
|
||||
- Other
|
||||
- tech_name: LinkedIn
|
||||
tech_logo: https://www.svgrepo.com/show/521725/linkedin.svg
|
||||
project_site: https://www.linkedin.com/in/brock-tomlinson/
|
||||
skill_level: 40
|
||||
tech_cat:
|
||||
- Other
|
||||
- tech_name: Twitch
|
||||
tech_logo: https://www.svgrepo.com/show/519925/twitch.svg
|
||||
project_site: https://www.twitch.tv/darkicewolf50
|
||||
skill_level: 60
|
||||
tech_cat:
|
||||
- Other
|
||||
- tech_name: Youtube
|
||||
tech_logo: https://www.svgrepo.com/show/521936/youtube.svg
|
||||
project_site: https://www.youtube.com/@darkicewolf50
|
||||
skill_level: 40
|
||||
tech_cat:
|
||||
- Other
|
||||
- tech_name: Internet
|
||||
tech_logo: https://www.svgrepo.com/show/490809/internet.svg
|
||||
project_site: https://google.com
|
||||
skill_level: 99
|
||||
tech_cat:
|
||||
- Other
|
116
src/lib.rs
116
src/lib.rs
@ -1,33 +1,32 @@
|
||||
use actix_web::{HttpResponse, Responder, get, post, web};
|
||||
use actix_web::{HttpRequest, Responder, get, web};
|
||||
// use actix_web::{HttpResponse, post};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::json;
|
||||
use std::fs;
|
||||
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
pub fn log_incoming(req: HttpRequest, method: &str, path_source: &str) {
|
||||
let peer_addr = req.peer_addr();
|
||||
if let Some(ip_addr_other) = peer_addr {
|
||||
println!(
|
||||
"{} request from: {}, subaddress: {}",
|
||||
method, ip_addr_other, path_source
|
||||
);
|
||||
} else {
|
||||
println!(
|
||||
"{} request from: unknown, subaddress: {}",
|
||||
method, path_source
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[get("/")]
|
||||
pub async fn hello() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello world!")
|
||||
}
|
||||
|
||||
#[post("/echo")]
|
||||
pub async fn echo(req_body: String) -> impl Responder {
|
||||
HttpResponse::Ok().body(req_body)
|
||||
}
|
||||
|
||||
pub async fn manual_hello() -> impl Responder {
|
||||
HttpResponse::Ok().body("Hello there!\nGeneral Kenobi")
|
||||
}
|
||||
|
||||
// the path to get to the html response
|
||||
#[get("/resend")]
|
||||
// function signature, data that is passed in, return type must implement the Responder trait
|
||||
pub async fn resend(req_body: String) -> impl Responder {
|
||||
// this returns a html response with a 200 code
|
||||
// this should be used for final serialization
|
||||
// possibly main functionality
|
||||
HttpResponse::Ok().body(req_body)
|
||||
pub async fn hello(req: HttpRequest) -> impl Responder {
|
||||
log_incoming(req, "GET", "/");
|
||||
web::Json(json!({
|
||||
"body": {
|
||||
"message": "Hello I am alive, this does nothing"
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
@ -40,8 +39,9 @@ struct TechDes {
|
||||
}
|
||||
|
||||
#[get("/skills")]
|
||||
pub async fn skills_home() -> impl Responder {
|
||||
let raw_yaml: String = fs::read_to_string("./src/data_txt/skill_level.yaml").unwrap();
|
||||
pub async fn skills_home(req: HttpRequest) -> impl Responder {
|
||||
log_incoming(req, "GET", "/skills");
|
||||
let raw_yaml: String = fs::read_to_string("./data_txt/skill_level.yaml").unwrap();
|
||||
// .expect("Cannot open file or missing file.");
|
||||
let vec_yaml = yaml_rust2::YamlLoader::load_from_str(&raw_yaml).unwrap()[0].clone();
|
||||
|
||||
@ -66,13 +66,59 @@ pub async fn skills_home() -> impl Responder {
|
||||
web::Json(res_vec)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
}
|
||||
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||
struct ProjectDes {
|
||||
project_name: String,
|
||||
website_link: String,
|
||||
github_link: String,
|
||||
project_img: String,
|
||||
techs_used: Vec<String>,
|
||||
project_des: String,
|
||||
}
|
||||
|
||||
#[get("/projects/{num_limit}")]
|
||||
pub async fn project(limit: web::Path<usize>, req: HttpRequest) -> impl Responder {
|
||||
log_incoming(req, "GET", "/projects/{num_limit}");
|
||||
|
||||
let limit = limit.into_inner();
|
||||
|
||||
let raw_yaml: String = fs::read_to_string("./data_txt/projects.yaml").unwrap();
|
||||
let vec_yaml = yaml_rust2::YamlLoader::load_from_str(&raw_yaml).unwrap()[0].clone();
|
||||
|
||||
let raw_vec: Vec<ProjectDes> = vec_yaml
|
||||
.as_vec()
|
||||
.unwrap_or(&vec![])
|
||||
.iter()
|
||||
.map(|item| ProjectDes {
|
||||
project_name: item["project_name"].as_str().unwrap_or("").to_string(),
|
||||
website_link: item["website_link"].as_str().unwrap_or("").to_string(),
|
||||
github_link: item["github_link"].as_str().unwrap_or("").to_string(),
|
||||
project_img: item["project_img"].as_str().unwrap_or("").to_string(),
|
||||
techs_used: item["techs_used"]
|
||||
.as_vec()
|
||||
.unwrap_or(&vec![])
|
||||
.iter()
|
||||
.filter_map(|item_str| item_str.as_str().map(|inner_item| inner_item.to_string()))
|
||||
.collect(),
|
||||
project_des: item["project_des"].as_str().unwrap_or("").to_string(),
|
||||
})
|
||||
.collect();
|
||||
let res_vec: Vec<ProjectDes> = if limit == 0 || limit >= raw_vec.len() {
|
||||
raw_vec
|
||||
} else {
|
||||
raw_vec[..limit].to_vec()
|
||||
};
|
||||
|
||||
web::Json(res_vec)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod tests {
|
||||
// use super::*;
|
||||
|
||||
// #[test]
|
||||
// fn it_works() {
|
||||
// let result = add(2, 2);
|
||||
// assert_eq!(result, 4);
|
||||
// }
|
||||
// }
|
||||
|
10
src/main.rs
10
src/main.rs
@ -1,15 +1,17 @@
|
||||
use actix_web::{App, HttpServer, web};
|
||||
|
||||
use darkicewolf50_cloud::{echo, hello, manual_hello, resend, skills_home};
|
||||
use darkicewolf50_cloud::{hello, project, skills_home};
|
||||
// use darkicewolf50_cloud:: {echo, manual_hello, resend,};
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
.service(hello)
|
||||
.service(echo)
|
||||
.service(resend)
|
||||
.route("/hey", web::get().to(manual_hello))
|
||||
// .service(echo)
|
||||
// .service(resend)
|
||||
// .route("/hey", web::get().to(manual_hello))
|
||||
.service(project)
|
||||
.service(web::scope("/home").service(skills_home))
|
||||
})
|
||||
.bind(("127.0.0.1", 8080))?
|
||||
|
Reference in New Issue
Block a user