-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathindex.js
48 lines (40 loc) · 1.27 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
const express = require("express");
const morgan = require("morgan");
const cors = require("cors");
const bodyParser = require("body-parser");
const verifyToken = require("./verifyToken");
const mongoose = require("mongoose");
const config = require("./config");
const app = express();
const authRouter = require("./auth");
const userCreate = require("./Routes/userCreate");
const subjectRouter = require("./Routes/subjectRoute")
const teacherRouter = require("./Routes/teacherRoute")
const attendanceRouter = require("./Routes/attendanceRoute")
const enrollmentRouter = require("./Routes/EnrollmentRoute")
app.use(morgan("dev"));
app.use(cors());
app.use(bodyParser.json());
mongoose
.connect(config.mongoUrl, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false,
autoIndex: true,
useCreateIndex: true,
})
.then((v) => {
console.log("Mongoose connection established successfully");
});
app.get("/", verifyToken, (req, res, next) => {
res.json({ test: "Hello World" });
});
app.use("/", authRouter);
app.use("/", userCreate);
app.use("/", subjectRouter);
app.use("/", teacherRouter);
app.use("/", attendanceRouter);
app.use("/", enrollmentRouter);
app.listen(config.PORT, () => {
console.log(`Server running at ${config.PORT}`);
});