|
1 | | -import path, { dirname } from 'path'; |
2 | | -import { fileURLToPath } from 'url'; |
3 | | -import express from 'express'; |
4 | | -import morgan from 'morgan'; |
5 | | -import cookieParser from 'cookie-parser'; |
6 | | -import cors from 'cors'; |
7 | | -import { logger } from '#util'; |
8 | | -import indexRouter from '#routes/index'; |
9 | | -import usersRouter from '#routes/users'; |
10 | | -import authRouter from '#routes/auth'; |
11 | | -import accreditationRouter from '#routes/accreditation'; |
12 | | -import infrastructureRouter from '#routes/infrastructure'; |
13 | | -import practicalRouter from '#routes/practical'; |
14 | | -import organizationRouter from '#routes/organization'; |
15 | | -import studentRouter from '#routes/student'; |
16 | | -import tutorialRouter from '#routes/tutorial'; |
17 | | -import assignmentRouter from '#routes/assignment'; |
18 | | -import timetableRouter from '#routes/timetable'; |
19 | | -import courseworkRouter from '#routes/coursework'; |
20 | | -import moduleRouter from '#routes/module'; |
21 | | -import { identifyUser } from '#middleware/identifyUser'; |
22 | | -import departmentRouter from '#routes/department'; |
23 | | -import examRouter from '#routes/exam'; |
| 1 | +import path, { dirname } from "path"; |
| 2 | +import { fileURLToPath } from "url"; |
| 3 | +import express from "express"; |
| 4 | +import morgan from "morgan"; |
| 5 | +import cookieParser from "cookie-parser"; |
| 6 | +import cors from "cors"; |
| 7 | +import { logger } from "#util"; |
| 8 | +import indexRouter from "#routes/index"; |
| 9 | +import usersRouter from "#routes/users"; |
| 10 | +import authRouter from "#routes/auth"; |
| 11 | +import accreditationRouter from "#routes/accreditation"; |
| 12 | +import infrastructureRouter from "#routes/infrastructure"; |
| 13 | +import practicalRouter from "#routes/practical"; |
| 14 | +import organizationRouter from "#routes/organization"; |
| 15 | +import studentRouter from "#routes/student"; |
| 16 | +import tutorialRouter from "#routes/tutorial"; |
| 17 | +import assignmentRouter from "#routes/assignment"; |
| 18 | +import timetableRouter from "#routes/timetable"; |
| 19 | +import courseworkRouter from "#routes/coursework"; |
| 20 | +import moduleRouter from "#routes/module"; |
| 21 | +import { identifyUser } from "#middleware/identifyUser"; |
| 22 | +import departmentRouter from "#routes/department"; |
| 23 | +import examRouter from "#routes/exam"; |
24 | 24 |
|
25 | 25 | const app = express(); |
26 | 26 | const currDirName = dirname(fileURLToPath(import.meta.url)); |
27 | 27 |
|
28 | | -morgan.token('remote-user', (req) => req.user); |
| 28 | +morgan.token("remote-user", (req) => req.user); |
29 | 29 | app.use(identifyUser); |
30 | 30 | app.use(cors()); |
31 | 31 | app.use(express.json()); |
32 | 32 | app.use(express.urlencoded({ extended: false })); |
33 | 33 | app.use(cookieParser()); |
34 | 34 | app.use( |
35 | 35 | morgan( |
36 | | - ':remote-addr - :remote-user ":method :url HTTP/:http-version" :status ":referrer" ":user-agent"', |
37 | | - { stream: logger.stream } |
38 | | - ) |
| 36 | + ":remote-addr - :remote-user \":method :url HTTP/:http-version\" :status \":referrer\" \":user-agent\"", |
| 37 | + { stream: logger.stream }, |
| 38 | + ), |
39 | 39 | ); |
40 | 40 |
|
41 | | -app.use(express.static(path.join(currDirName, 'public'))); |
| 41 | +app.use(express.static(path.join(currDirName, "public"))); |
42 | 42 |
|
43 | | -app.use('/', indexRouter); |
44 | | -app.use('/users', usersRouter); |
45 | | -app.use('/auth', authRouter); |
46 | | -app.use('/accreditation', accreditationRouter); |
47 | | -app.use('/infrastructure', infrastructureRouter); |
48 | | -app.use('/department', departmentRouter); |
49 | | -app.use('/practical', practicalRouter); |
50 | | -app.use('/organization', organizationRouter); |
51 | | -app.use('/student', studentRouter); |
52 | | -app.use('/tutorial', tutorialRouter); |
53 | | -app.use('/assignment', assignmentRouter); |
54 | | -app.use('/timetable', timetableRouter); |
55 | | -app.use('/department', departmentRouter); |
56 | | -app.use('/coursework', courseworkRouter); |
57 | | -app.use('/module', moduleRouter); |
58 | | -app.use('/exam', examRouter); |
| 43 | +app.use("/", indexRouter); |
| 44 | +app.use("/users", usersRouter); |
| 45 | +app.use("/auth", authRouter); |
| 46 | +app.use("/accreditation", accreditationRouter); |
| 47 | +app.use("/infrastructure", infrastructureRouter); |
| 48 | +app.use("/department", departmentRouter); |
| 49 | +app.use("/practical", practicalRouter); |
| 50 | +app.use("/organization", organizationRouter); |
| 51 | +app.use("/student", studentRouter); |
| 52 | +app.use("/tutorial", tutorialRouter); |
| 53 | +app.use("/assignment", assignmentRouter); |
| 54 | +app.use("/timetable", timetableRouter); |
| 55 | +app.use("/department", departmentRouter); |
| 56 | +app.use("/coursework", courseworkRouter); |
| 57 | +app.use("/module", moduleRouter); |
| 58 | +app.use("/exam", examRouter); |
59 | 59 |
|
60 | 60 | export default app; |
0 commit comments