graphdbhue3/src/main.rs

67 lines
1.4 KiB
Rust
Raw Normal View History

2024-05-24 13:09:17 +02:00
use neo4rs::{Graph, Node, query};
use rocket::Config;
use rocket_okapi::swagger_ui::{make_swagger_ui, SwaggerUIConfig};
use crate::backend::backend::build_api;
mod backend;
fn main() {
println!("Hello, world!");
let t = tokio::runtime::Runtime::new().unwrap();
let tt = Box::new("hello".to_string());
let iii = 1;
for i in 1..5 {
if tt == "hello" {
println!("{tt}");
} else {
println!("not");
}
}
println!("{tt}");
t.block_on(async move {
// concurrent queries
let uri: String = "127.0.0.1:7687".to_string();
let user = "neo4j";
let pass = "neo";
let graph = Graph::new(uri, user, pass).await.unwrap();
//println!("{uri}");
let config = Config {
address: "0.0.0.0".parse().unwrap(),
port: 8081,
..Default::default()
};
let rock = rocket::custom(config)
.manage(graph)
.mount("/api/", build_api())
.mount(
"/docs/",
make_swagger_ui(&SwaggerUIConfig {
url: "../api/openapi.json".to_owned(),
..Default::default()
}),
);
let rock = rock.launch().await;
match rock {
Ok(_) => println!("Rocket shut down gracefully."),
Err(err) => println!("Rocket had an error: {}", err),
};
});
}