-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
61 lines (48 loc) · 1.99 KB
/
index.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
require("dotenv").config();
const express = require("express");
const mongoose = require("mongoose");
const cors = require("cors");
const app = express();
const DB_URL = process.env.DB_URI;
const PORT = process.env.PORT || 8000;
app.use(express.json());
app.use(cors());
app.use(
express.urlencoded({
extended: true,
})
);
const FeedbackController = require("./controllers/feedbackController");
const TimetableController = require("./controllers/timetableController");
const CoursesControllers = require("./controllers/coursesController");
mongoose
.connect(DB_URL, { useNewUrlParser: true, useUnifiedTopology: true })
.then(() => {
console.log("✅ Database Connected!");
})
.catch((err) => {
console.log("DB connect error:", err);
});
app.get("/", (req, res) => {
res.send("The server is running!");
});
//Use the routes inside this block to populate the db in the beginning. Do not use this in production.
const InitialController = require("./controllers/initialController");
app.get("/createClasses", InitialController.createClasses);
app.get("/createFeedback", InitialController.createFeedback);
app.get("/createCourses", InitialController.createCourses);
app.get("/view-teachers", FeedbackController.viewTeachers);
app.post("/view-teachers", FeedbackController.viewTeachersForCourse);
app.post("/update-feedback", FeedbackController.updateFeedback);
app.get("/view-teachers-old", FeedbackController.viewTeachersOld);
app.post("/view-teachers", FeedbackController.viewTeachersOldForCourse);
app.post("/update-feedback", FeedbackController.updateOldFeedback);
app.get("/view-courses", CoursesControllers.viewCourses);
app.post("/all-timetables", TimetableController.allTimetables);
app.post("/save-timetable", TimetableController.saveTimetable);
app.get("/view-saved", TimetableController.viewSaved);
app.post("/view-slots", TimetableController.slotsForTeacher);
app.listen(PORT, () => {
console.log("🚀 Server Ready! at port:", PORT);
console.log("Goto http://localhost:" + PORT);
});