-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
73 lines (60 loc) · 1.68 KB
/
app.js
File metadata and controls
73 lines (60 loc) · 1.68 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// import dependencies
const express = require("express");
const favicon = require("serve-favicon");
const path = require("path");
const session = require("express-session");
// initialise express app
const app = express();
// view engine
app.set("view engine", "ejs");
// directory for static files
app.use(express.static(path.join(__dirname, "public")));
// favicon
app.use(favicon(path.join(__dirname, "public", "images", "favicon.png")));
// parse HTML form
app.use(express.urlencoded({ extended: true }));
// prase JSON bodies (as sent by API clients)
app.use(express.json());
// express-sessions
app.use(
session({
secret: "secret-key",
resave: false,
saveUninitialized: false,
})
);
// sweet alerts - allow public access
app.use(
"/swal",
express.static(path.join(__dirname, "/node_modules/sweetalert2"))
);
// cytoscape modules - allow public access
app.use(
"/cytoscape",
express.static(path.join(__dirname, "/node_modules/cytoscape"))
);
app.use(
"/cytoscape-fcose",
express.static(path.join(__dirname, "/node_modules/cytoscape-fcose"))
);
app.use(
"/layout-base",
express.static(path.join(__dirname, "node_modules/layout-base"))
);
app.use(
"/cose-base",
express.static(path.join(__dirname, "node_modules/cose-base"))
);
// define routes
app.use("/", require("./routes/homepage"));
app.use("/information", require("./routes/information"));
app.use("/input", require("./routes/input"));
app.use("/visualise", require("./routes/visualise"));
// 404 route
app.use("*", require("./routes/404"));
// establishing port connection
const PORT = process.env.PORT || 3000;
// listen for requests
app.listen(PORT, () => {
console.log("Listening on port 3000: http://localhost:3000");
});