-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.js
58 lines (49 loc) · 1.72 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
const express = require("express");
const mongoose = require("mongoose");
const dotenv = require("dotenv");
const cors = require("cors");
const teachersRoute = require("./src/routes/teacher");
const studentRoute = require("./src/routes/student");
const timetableRoute = require("./src/routes/timetable");
const inventoryRoute = require("./src/routes/inventory");
const eventRoute = require("./src/routes/event");
const adminRoute = require("./src/routes/admin");
const examRoute = require("./src/routes/exam");
const resultRoute = require("./src/routes/result");
const tutorialRoute = require("./src/routes/tutorial");
const HallRoute = require("./src/routes/Hall");
const LoginRoute = require("./src/routes/login");
const requestRoute = require("./src/routes/request");
const app = express();
dotenv.config();
app.use(cors());
mongoose
.connect(process.env.MONGODB_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
})
.then(() => console.log("DB Connection successful"))
.catch((err) => {
console.log(err);
});
//Middleware
app.use(express.json());
app.get("/", (req, res) => {
res.send("Welcom to BrainTech");
console.log(process.env.PORT);
});
app.use("/api/teacher", teachersRoute);
app.use("/api/student", studentRoute);
app.use("/api/timetable", timetableRoute);
app.use("/api/inventory", inventoryRoute);
app.use("/api/event", eventRoute);
app.use("/api/admin", adminRoute);
app.use("/api/exam", examRoute);
app.use("/api/result", resultRoute);
app.use("/api/tutorial",tutorialRoute);
app.use("/api/hall", HallRoute);
app.use("/api/login", LoginRoute);
app.use("/api/request", requestRoute);
app.listen(process.env.PORT || 5000, () =>
console.log(`Server is up and running on PORT ${process.env.PORT}`)
);