-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
56 lines (46 loc) · 1.78 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
const express = require("express");
// const path = require("path");
// const neo4j = require("neo4j-driver").v1;
const index = require("./routes/index");
const app = express();
const port = process.env.PORT || 5000;
var testAPIRouter = require("./api");
// const driver = neo4j.driver("bolt://localhost", neo4j.auth.basic("neo4j", "admin"));
// const session = driver.session();
// API calls
app.use("/api", index);
app.get("*", (req, res) => {
res.sendFile("/public/index.html", { root: global });
});
// app.get("/testAPI", testAPIRouter);
// app.get("/users", (req, res) => {
// console.log("yassine");
// session
// .run("MATCH (n:Artist) RETURN n")
// .then(response => {
// response.records.map(artist => {
// console.log("res: " + JSON.stringify(artist._fields));
// });
// res.json({ data: "tj" });
// res.render(path.join(__dirname, "/public/index.html"), { data: "Hello From Express" });
// })
// .catch(error => console.log("error" + JSON.stringify(error)));
// });
// if (process.env.NODE_ENV === "production") {
// // Serve any static files
// app.use(express.static(path.join(__dirname, "public")));
// // Handle React routing, return all requests to React app
// app.get("*", (req, res) => {
// session
// .run("MATCH (n:Artist) RETURN n")
// .then(res => {
// // console.log("res: " + JSON.stringify(res.records._fields[0]));
// })
// .catch(error => console.log("error" + JSON.stringify(error)));
// res.sendFile(path.join(__dirname, "/public/index.html"));
// });
// }
// Create
// session.run("CREATE (a:Person {name: $name}) RETURN a", { name: personName });
// Get
app.listen(port, () => console.log(`Listening on port ${port}`));