2024-01-14 02:57:13 +00:00
|
|
|
use actix_web::{get, HttpRequest, Responder};
|
2024-01-16 08:02:23 +00:00
|
|
|
|
2024-05-03 16:22:59 +00:00
|
|
|
mod cache;
|
|
|
|
mod db;
|
2024-01-14 02:57:13 +00:00
|
|
|
mod item;
|
2024-04-04 05:41:13 +00:00
|
|
|
mod routes;
|
2024-05-03 16:22:59 +00:00
|
|
|
mod transaction;
|
|
|
|
mod variant;
|
2024-01-14 02:57:13 +00:00
|
|
|
|
|
|
|
// ░░░░░░░░░░▀▀▀██████▄▄▄░░░░░░░░░░
|
|
|
|
// ░░░░░░░░░░░░░░░░░▀▀▀████▄░░░░░░░
|
|
|
|
// ░░░░░░░░░░▄███████▀░░░▀███▄░░░░░
|
|
|
|
// ░░░░░░░░▄███████▀░░░░░░░▀███▄░░░
|
|
|
|
// ░░░░░░▄████████░░░░░░░░░░░███▄░░
|
2024-01-16 08:02:23 +00:00
|
|
|
// ░░░░░██████████▄░░░░░░░░░░░███▌░ ▒█▀▀█ █▀▀█ █▀▄▀█ █▀▄▀█ ▒█▀▀▄ ▒█▀▀█
|
|
|
|
// ░░░░░▀█████▀░▀███▄░░░░░░░░░▐███░ ▒█░░░ █░░█ █░▀░█ █░▀░█ ▒█░▒█ ▒█▀▀▄
|
2024-01-14 02:57:13 +00:00
|
|
|
// ░░░░░░░▀█▀░░░░░▀███▄░░░░░░░▐███░ ▒█▄▄█ ▀▀▀▀ ▀░░░▀ ▀░░░▀ ▒█▄▄▀ ▒█▄▄█
|
|
|
|
// ░░░░░░░░░░░░░░░░░▀███▄░░░░░███▌░
|
|
|
|
// ░░░░▄██▄░░░░░░░░░░░▀███▄░░▐███░░
|
|
|
|
// ░░▄██████▄░░░░░░░░░░░▀███▄███░░░
|
|
|
|
// ░█████▀▀████▄▄░░░░░░░░▄█████░░░░
|
|
|
|
// ░████▀░░░▀▀█████▄▄▄▄█████████▄░░
|
|
|
|
// ░░▀▀░░░░░░░░░▀▀██████▀▀░░░▀▀██░░
|
|
|
|
|
|
|
|
#[get("/")]
|
|
|
|
pub(crate) async fn index(r: HttpRequest) -> impl Responder {
|
2024-05-03 16:22:59 +00:00
|
|
|
let itemdb: &actix_web::web::Data<db::ItemDB> = r.app_data().unwrap();
|
2024-04-04 05:41:13 +00:00
|
|
|
let content = "";
|
2024-01-14 02:57:13 +00:00
|
|
|
web_base::func::build_site(&r, "Index", &content)
|
|
|
|
}
|
|
|
|
|
|
|
|
#[actix_web::main]
|
|
|
|
async fn main() -> std::io::Result<()> {
|
|
|
|
env_logger::init();
|
|
|
|
|
2024-05-10 08:56:07 +00:00
|
|
|
let itemdb = db::ItemDB::new("./itemdb").await;
|
2024-01-14 02:57:13 +00:00
|
|
|
let itemdb = actix_web::web::Data::new(itemdb);
|
|
|
|
|
2024-04-04 05:41:13 +00:00
|
|
|
web_base::map!(web_base::Site::new(), |app: actix_web::App<_>| {
|
|
|
|
app.app_data(itemdb.clone())
|
|
|
|
.service(index)
|
2024-05-10 10:00:57 +00:00
|
|
|
.service(routes::item::supply_route) // /supply
|
|
|
|
.service(routes::item::item_variants_page) // /item/{item_id}/variants
|
|
|
|
.service(routes::item::get_items_route) // /items
|
|
|
|
.service(routes::item::demand_route) // /demand
|
|
|
|
.service(routes::item::supply_log_route) // /item/{item_id}/{variant_id}/supply
|
|
|
|
.service(routes::item::demand_log_route) // /item/{item_id}/{variant_id}/demand
|
2024-04-04 05:41:13 +00:00
|
|
|
})
|
2024-01-14 02:57:13 +00:00
|
|
|
.bind(("0.0.0.0".to_string(), 8080))?
|
|
|
|
.run()
|
|
|
|
.await
|
|
|
|
}
|