-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
app.js
82 lines (77 loc) · 3.03 KB
/
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
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
74
75
76
77
78
79
80
81
82
import path, { dirname } from "path";
import { fileURLToPath } from "url";
import express from "express";
import morgan from "morgan";
import cookieParser from "cookie-parser";
import cors from "cors";
import { logger } from "#util";
import indexRouter from "#routes/index";
import usersRouter from "#routes/users";
import authRouter from "#routes/auth";
import semesterRouter from "#routes/semester";
import accreditationRouter from "#routes/accreditation";
import infrastructureRouter from "#routes/infrastructure";
import practicalRouter from "#routes/practical";
import organizationRouter from "#routes/organization";
import studentRouter from "#routes/student";
import tutorialRouter from "#routes/tutorial";
import assignmentRouter from "#routes/assignment";
import timetableRouter from "#routes/timetable";
import courseworkRouter from "#routes/coursework";
import activityRouter from "#routes/activity";
import moduleRouter from "#routes/module";
import facultyRouter from "#routes/faculty";
import { identifyUser } from "#middleware/identifyUser";
import departmentRouter from "#routes/department";
import attendanceRouter from "#routes/attendance";
import examRouter from "#routes/exam";
import paperRouter from "#routes/paper";
import groupRouter from "#routes/group";
import performarouter from "#routes/performance";
import notificationRouter from "#routes/notification";
import topicRouter from "#routes/topic";
import courseRouter from "#routes/course";
import activityBlueprintRouter from "#routes/activityBlueprint";
const app = express();
const currDirName = dirname(fileURLToPath(import.meta.url));
morgan.token("remote-user", (req) => req.user);
app.use(identifyUser);
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(
morgan(
":remote-addr - :remote-user \":method :url HTTP/:http-version\" :status \":referrer\" \":user-agent\"",
{ stream: logger.stream },
),
);
app.use(express.static(path.join(currDirName, "public")));
app.use("/", indexRouter);
app.use("/users", usersRouter);
app.use("/auth", authRouter);
app.use("/accreditation", accreditationRouter);
app.use("/infrastructure", infrastructureRouter);
app.use("/department", departmentRouter);
app.use("/practical", practicalRouter);
app.use("/organization", organizationRouter);
app.use("/student", studentRouter);
app.use("/activity", activityRouter);
app.use("/tutorial", tutorialRouter);
app.use("/assignment", assignmentRouter);
app.use("/timetable", timetableRouter);
app.use("/department", departmentRouter);
app.use("/coursework", courseworkRouter);
app.use("/module", moduleRouter);
app.use("/attendance", attendanceRouter);
app.use("/exam", examRouter);
app.use("/paper", paperRouter);
app.use("/group", groupRouter);
app.use("/semester", semesterRouter);
app.use("/faculty", facultyRouter);
app.use("/performance", performarouter);
app.use("/notification", notificationRouter);
app.use("/topic", topicRouter);
app.use("/course", courseRouter);
app.use("/activityBlueprint", activityBlueprintRouter);
export default app;