init
This commit is contained in:
commit
e589e974db
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
2176
Cargo.lock
generated
Normal file
2176
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
Cargo.toml
Normal file
13
Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "graphdbhue3"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
neo4rs = "0.7.1"
|
||||||
|
tokio = "1.37.0"
|
||||||
|
rocket = "0.5.0"
|
||||||
|
rocket_okapi = { version = "0.8.0", features = ["swagger"] }
|
||||||
|
anyhow = "1.0.76"
|
21
src/backend/backend.rs
Normal file
21
src/backend/backend.rs
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
use neo4rs::Graph;
|
||||||
|
use rocket::{get, Route, State};
|
||||||
|
use rocket::response::status::NotFound;
|
||||||
|
use rocket_okapi::{openapi, openapi_get_routes};
|
||||||
|
use rocket::serde::json::Json;
|
||||||
|
|
||||||
|
|
||||||
|
pub fn build_api() -> Vec<Route> {
|
||||||
|
openapi_get_routes![
|
||||||
|
append
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/// get general build-server stats
|
||||||
|
#[openapi(tag = "stats")]
|
||||||
|
#[get("/append")]
|
||||||
|
pub async fn append(graph: &State<Graph>) -> Result<String, NotFound<String>> {
|
||||||
|
let graph = graph as &Graph;
|
||||||
|
|
||||||
|
Ok("worked".to_string())
|
||||||
|
}
|
1
src/backend/mod.rs
Normal file
1
src/backend/mod.rs
Normal file
@ -0,0 +1 @@
|
|||||||
|
pub mod backend;
|
66
src/main.rs
Normal file
66
src/main.rs
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
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),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user