2024-09-12 08:34:14 +00:00
|
|
|
use flow::FlowInfo;
|
2024-09-02 16:40:02 +00:00
|
|
|
use json_store::JSONStore;
|
|
|
|
use location::Location;
|
2024-09-03 09:16:45 +00:00
|
|
|
|
2024-06-21 19:14:45 +00:00
|
|
|
use rocket::routes as route;
|
|
|
|
use rocket::{http::Method, launch};
|
2024-01-16 08:02:23 +00:00
|
|
|
|
2024-09-08 00:37:39 +00:00
|
|
|
mod config;
|
2024-05-03 16:22:59 +00:00
|
|
|
mod db;
|
2024-09-09 19:49:36 +00:00
|
|
|
mod flow;
|
2024-09-19 09:42:59 +00:00
|
|
|
mod integrity;
|
2024-01-14 02:57:13 +00:00
|
|
|
mod item;
|
2024-09-02 16:40:02 +00:00
|
|
|
mod json_store;
|
|
|
|
mod location;
|
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
|
|
|
// ░░░░░░░▀█▀░░░░░▀███▄░░░░░░░▐███░ ▒█▄▄█ ▀▀▀▀ ▀░░░▀ ▀░░░▀ ▒█▄▄▀ ▒█▄▄█
|
|
|
|
// ░░░░░░░░░░░░░░░░░▀███▄░░░░░███▌░
|
|
|
|
// ░░░░▄██▄░░░░░░░░░░░▀███▄░░▐███░░
|
|
|
|
// ░░▄██████▄░░░░░░░░░░░▀███▄███░░░
|
|
|
|
// ░█████▀▀████▄▄░░░░░░░░▄█████░░░░
|
|
|
|
// ░████▀░░░▀▀█████▄▄▄▄█████████▄░░
|
|
|
|
// ░░▀▀░░░░░░░░░▀▀██████▀▀░░░▀▀██░░
|
|
|
|
|
2024-06-21 19:14:45 +00:00
|
|
|
#[launch]
|
|
|
|
async fn rocket() -> _ {
|
2024-08-28 20:03:39 +00:00
|
|
|
env_logger::init();
|
|
|
|
|
2024-06-21 19:14:45 +00:00
|
|
|
let cors = rocket_cors::CorsOptions {
|
|
|
|
allowed_origins: rocket_cors::AllowedOrigins::all(),
|
|
|
|
allowed_methods: vec![Method::Get, Method::Post, Method::Options]
|
|
|
|
.into_iter()
|
|
|
|
.map(From::from)
|
|
|
|
.collect(),
|
|
|
|
allowed_headers: rocket_cors::AllowedHeaders::all(),
|
|
|
|
allow_credentials: true,
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
.to_cors()
|
|
|
|
.expect("error creating CORS options");
|
2024-01-14 02:57:13 +00:00
|
|
|
|
2024-09-19 09:42:59 +00:00
|
|
|
let config = config::get_config();
|
2024-05-10 08:56:07 +00:00
|
|
|
let itemdb = db::ItemDB::new("./itemdb").await;
|
2024-09-12 08:17:14 +00:00
|
|
|
let mut locations: JSONStore<Location> = JSONStore::new("./locations");
|
2024-09-19 09:42:59 +00:00
|
|
|
let mut flows: JSONStore<FlowInfo> = JSONStore::new("./flows");
|
|
|
|
integrity::verify_integrity(&config, &flows, &locations, &itemdb).await;
|
2024-09-02 16:40:02 +00:00
|
|
|
|
2024-09-12 09:54:52 +00:00
|
|
|
for location in &mut *locations {
|
2024-09-12 08:17:14 +00:00
|
|
|
location.1.add(location.0).await;
|
2024-09-02 16:40:02 +00:00
|
|
|
}
|
2024-01-14 02:57:13 +00:00
|
|
|
|
2024-09-12 09:54:52 +00:00
|
|
|
for flow in &mut *flows {
|
2024-09-12 08:34:14 +00:00
|
|
|
flow.1.add(flow.0).await;
|
|
|
|
}
|
|
|
|
|
2024-06-21 19:14:45 +00:00
|
|
|
rocket::build()
|
|
|
|
.mount(
|
|
|
|
"/",
|
|
|
|
route![
|
|
|
|
routes::item::get_items_route,
|
2024-06-22 00:05:22 +00:00
|
|
|
routes::item::item_route,
|
2024-06-21 19:14:45 +00:00
|
|
|
routes::item::item_variants_page,
|
|
|
|
routes::item::supply_log_route,
|
|
|
|
routes::item::demand_log_route,
|
|
|
|
routes::item::supply_route,
|
|
|
|
routes::item::demand_route,
|
2024-08-13 02:13:38 +00:00
|
|
|
routes::item::transaction_route,
|
2024-08-27 21:33:09 +00:00
|
|
|
routes::item::inventory_route,
|
2024-09-05 08:33:34 +00:00
|
|
|
routes::item::inventory_route_variant,
|
2024-08-28 20:03:39 +00:00
|
|
|
routes::item::variant_stat_route,
|
2024-09-02 16:43:42 +00:00
|
|
|
routes::item::unique_field_route,
|
|
|
|
routes::item::location_info,
|
2024-09-05 08:33:34 +00:00
|
|
|
routes::item::locations_info,
|
2024-09-12 08:34:14 +00:00
|
|
|
routes::item::locations_list,
|
|
|
|
routes::item::location_inventory,
|
|
|
|
routes::flow::flow_info,
|
2024-09-12 08:58:49 +00:00
|
|
|
routes::flow::flows_list,
|
|
|
|
routes::item::expired_items_route,
|
2024-09-12 11:11:44 +00:00
|
|
|
routes::item::min_items_route,
|
2024-09-13 12:17:55 +00:00
|
|
|
routes::item::variant_price_history_by_origin,
|
|
|
|
routes::flow::end_flow_route,
|
|
|
|
routes::flow::continue_flow_route,
|
2024-09-13 20:33:21 +00:00
|
|
|
routes::flow::create_flow_route,
|
2024-09-16 06:10:26 +00:00
|
|
|
routes::item::move_transaction_route,
|
|
|
|
routes::item::variant_price_latest_by_origin
|
2024-06-21 19:14:45 +00:00
|
|
|
],
|
|
|
|
)
|
|
|
|
.manage(itemdb)
|
2024-09-02 16:40:02 +00:00
|
|
|
.manage(locations)
|
2024-09-12 08:34:14 +00:00
|
|
|
.manage(flows)
|
2024-09-08 00:37:39 +00:00
|
|
|
.manage(config)
|
2024-06-21 19:14:45 +00:00
|
|
|
.attach(cors)
|
2024-01-14 02:57:13 +00:00
|
|
|
}
|