-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
51 lines (46 loc) · 1.92 KB
/
index.ts
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
import * as dotenv from 'dotenv';
dotenv.config();
import express from "express";
import ActivityRoute from "./routes/Activity/Activity.route";
import AttendanceRoute from "./routes/Attendance/Attendance.route";
import ClassRoute from "./routes/Class/Class.route";
import DepartmentRoute from "./routes/Department/Department.route";
import GroupRoute from './routes/Group/Group.route';
import MajorRoute from "./routes/Major/Major.route";
import SemesterRoute from "./routes/Semester/Semester.route";
import SemesterStudentRoute from "./routes/SemesterStudent/SemesterStudent.route";
import StudentRoute from "./routes/Student/Student.route";
import ConfigurationRoute from "./routes/Configuration/Configuration.route";
import UserRoute from "./routes/User/User.route";
import YearRoute from "./routes/Year/Year.route";
import LoginRoute from "./routes/Login.route";
import authMiddleware from './middleware/authMiddleware';
import pg from "pg";
import path from 'path';
const types = pg.types;
const INT_OID = 20;
const TIMESTAMPTZ_OID = 1184;
const TIMESTAMP_OID = 1114;
types.setTypeParser(INT_OID, 'text', parseInt);
types.setTypeParser(TIMESTAMPTZ_OID, val => val);
types.setTypeParser(TIMESTAMP_OID, val => val);
const cors = require('cors');
const app = express();
app.use(express.json({limit: "1mb"}));
app.use(cors());
app.use("/public", express.static(path.join(__dirname, 'public')));
app.use(authMiddleware);
app.use("/", LoginRoute);
app.use("/groups", GroupRoute);
app.use("/departments", DepartmentRoute);
app.use("/users", UserRoute);
app.use("/majors", MajorRoute);
app.use("/classes", ClassRoute);
app.use("/students", StudentRoute);
app.use("/years", YearRoute);
app.use("/semesters", SemesterRoute);
app.use("/activities", ActivityRoute);
app.use("/configurations", ConfigurationRoute);
app.use("/attendance", AttendanceRoute);
app.use("/semester_students", SemesterStudentRoute);
app.listen(3100, () => console.log("Connected to server"));