-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.js
41 lines (34 loc) · 1.08 KB
/
app.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
const express = require("express");
const app = express();
app.use(express.json()); // for parsing application/json
require("dotenv").config();
const { PORT, MONGO_URI } = process.env;
// Swagger
const swaggerUi = require('swagger-ui-express')
const swaggerFile = require('./swagger-output.json')
app.use('/api', swaggerUi.serve, swaggerUi.setup(swaggerFile))
// MongoDB
const mongoose = require("mongoose");
async function connect() {
try {
await mongoose.connect(MONGO_URI);
console.log("MongoDB Connected");
} catch (e) {
console.error(e);
}
}
connect();
// Routes
const authRoutes = require("./routes/AuthRoute");
const userRoutes = require("./routes/UserRoute");
const semesterRoutes = require("./routes/SemesterRoute");
const groupRoutes = require("./routes/GroupRoute");
const memberRoutes = require("./routes/MemberRoute");
app.use("/auth", authRoutes);
app.use("/user", userRoutes);
app.use("/semester", semesterRoutes);
app.use("/group", groupRoutes);
app.use("/member", memberRoutes);
app.listen(PORT, () => {
console.log(`Server listening on port ${PORT}`);
});