use flow::FlowInfo; use json_store::JSONStore; use location::Location; use rocket::routes as route; use rocket::{http::Method, launch}; mod config; mod db; mod flow; mod integrity; mod item; mod json_store; mod location; mod routes; mod transaction; mod variant; // ░░░░░░░░░░▀▀▀██████▄▄▄░░░░░░░░░░ // ░░░░░░░░░░░░░░░░░▀▀▀████▄░░░░░░░ // ░░░░░░░░░░▄███████▀░░░▀███▄░░░░░ // ░░░░░░░░▄███████▀░░░░░░░▀███▄░░░ // ░░░░░░▄████████░░░░░░░░░░░███▄░░ // ░░░░░██████████▄░░░░░░░░░░░███▌░ ▒█▀▀█ █▀▀█ █▀▄▀█ █▀▄▀█ ▒█▀▀▄ ▒█▀▀█ // ░░░░░▀█████▀░▀███▄░░░░░░░░░▐███░ ▒█░░░ █░░█ █░▀░█ █░▀░█ ▒█░▒█ ▒█▀▀▄ // ░░░░░░░▀█▀░░░░░▀███▄░░░░░░░▐███░ ▒█▄▄█ ▀▀▀▀ ▀░░░▀ ▀░░░▀ ▒█▄▄▀ ▒█▄▄█ // ░░░░░░░░░░░░░░░░░▀███▄░░░░░███▌░ // ░░░░▄██▄░░░░░░░░░░░▀███▄░░▐███░░ // ░░▄██████▄░░░░░░░░░░░▀███▄███░░░ // ░█████▀▀████▄▄░░░░░░░░▄█████░░░░ // ░████▀░░░▀▀█████▄▄▄▄█████████▄░░ // ░░▀▀░░░░░░░░░▀▀██████▀▀░░░▀▀██░░ #[launch] async fn rocket() -> _ { env_logger::init(); 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"); let config = config::get_config(); let itemdb = db::ItemDB::new("./itemdb").await; let mut locations: JSONStore = JSONStore::new("./locations"); let mut flows: JSONStore = JSONStore::new("./flows"); integrity::verify_integrity(&config, &flows, &locations, &itemdb).await; for location in &mut *locations { location.1.add(location.0).await; } for flow in &mut *flows { flow.1.add(flow.0).await; } rocket::build() .mount( "/", route![ routes::item::get_items_route, routes::item::item_route, routes::item::item_variants_page, routes::item::supply_log_route, routes::item::demand_log_route, routes::item::supply_route, routes::item::demand_route, routes::item::transaction_route, routes::item::inventory_route, routes::item::inventory_route_variant, routes::item::variant_stat_route, routes::item::unique_field_route, routes::item::location_info, routes::item::locations_info, routes::item::locations_list, routes::item::location_inventory, routes::flow::flow_info, routes::flow::flows_list, routes::item::expired_items_route, routes::item::min_items_route, routes::item::variant_price_history_by_origin, routes::flow::end_flow_route, routes::flow::continue_flow_route, routes::flow::create_flow_route, routes::item::move_transaction_route, routes::item::variant_price_latest_by_origin, routes::item::item_stat_route, routes::flow::active_flows_route ], ) .manage(itemdb) .manage(locations) .manage(flows) .manage(config) .attach(cors) }