-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
33 lines (26 loc) · 895 Bytes
/
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
const express = require("express");
const { connectMongoDB } = require("./connection");
const router = require("./routes/");
const userRouter = require("./routes/user");
const questionRouter = require("./routes/question");
const answerRouter = require("./routes/answer");
const commentRouter = require("./routes/comment");
require("dotenv").config();
const app = express();
const PORT = process.env.PORT | 8000;
// Middlewares
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
// Connection
connectMongoDB(process.env.MONGO_URL).then(() =>
console.log("Connected to MongoDB")
);
// Routes
app.use("/", router);
app.use("/user", userRouter);
app.use("/question", questionRouter);
app.use("/answer", answerRouter);
app.use("/comment", commentRouter);
app.listen(PORT, () => {
console.log(`App Running on port ${PORT}`);
});