-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
39 lines (31 loc) · 953 Bytes
/
app.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
const express = require("express");
const cookieParser = require("cookie-parser");
const app = express();
// auth endpoint handler
const Internal = require("./routes/internal");
const Auth = require("./routes/auth");
const Admin = require("./routes/admin");
const Member = require("./routes/member");
const Public = require("./routes/public");
// middleware
const verifyRole = require("./middleware/role");
// parses string to json
app.use(express.json());
// parses cookie
app.use(cookieParser());
// logger
// app.all("*",(req,res,next)=> {
// console.log(`${req.originalUrl} -> ${req.body}`);
// next();
// })
// auth endpoint
app.use("/api/internal", verifyRole(0), Internal);
app.use("/api/auth", Auth);
app.use("/api/admin", verifyRole(1), Admin);
app.use("/api/member", verifyRole(2), Member);
app.use("/api/public", Public);
// test endpoint
app.get("/health", function (req, res) {
res.send("200 OK");
});
module.exports = app;