-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.mjs
More file actions
53 lines (49 loc) · 1.62 KB
/
server.mjs
File metadata and controls
53 lines (49 loc) · 1.62 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
import express from "express";
import bodyParser from "body-parser";
import cookieParser from "cookie-parser";
import { authorize } from "./authorize.mjs";
import { profile } from "./profile.mjs";
import { logout } from "./logout.mjs";
import { constraintCheck } from "./constraintCheck.mjs";
import { tripleCount } from "./tripleCount.mjs";
import { edit } from "./edit.mjs";
import { exists } from "./exists.mjs";
import { categoryScan } from "./categoryScan.mjs";
import { harvester } from "./harvester.mjs";
let app = express();
app.use(cookieParser());
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({
extended: true,
})
);
app.use(function (req, res, next) {
let origin = req.headers.origin;
if (!origin) {
origin = "*";
}
res.setHeader("Access-Control-Allow-Origin", origin);
res.header("Access-Control-Allow-Methods", "GET, OPTIONS");
res.header("Access-Control-Allow-Headers", "Content-Type, Authorization");
res.header("Access-Control-Allow-Credentials", true);
return next();
});
app.use("/static", express.static("public"));
let server = app.listen(process.env.PORT, function () {
let host = server.address().address;
let port = server.address().port;
console.log("Info: Listening at http://%s:%s", host, port);
});
app.get("/authorize", authorize);
app.get("/profile", profile);
app.get("/logout", logout);
app.get("/cc", constraintCheck);
app.get("/edit", edit);
app.get("/triplecount", tripleCount);
app.get("/exists", exists);
app.get("/categoryscan", categoryScan);
app.post("/harvester", harvester);
app.get("/", function (req, res) {
res.sendFile("doc.html", { root: "public" });
});