-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
52 lines (44 loc) · 1.3 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
require("dotenv").config();
const express = require("express");
const mongoose = require("mongoose");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const cors = require("cors");
const app = express();
const authRoutes = require("./routes/auth");
const userRoutes = require("./routes/user");
const likeRoutes = require("./routes/like");
const dislikeRoutes = require("./routes/dislike");
const videoRoutes = require("./routes/video");
const subscribeRoutes = require("./routes/subscribe");
const commentRoutes = require("./routes/comment");
mongoose
.connect(process.env.DATABASE, {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
})
.then(() => {
console.log("DB Connected");
})
.catch((error) => {
console.log(error);
});
app.use(bodyParser.json());
app.use(cookieParser());
app.use(cors());
app.use("/api", authRoutes);
app.use("/api", userRoutes);
app.use("/api", likeRoutes);
app.use("/api", dislikeRoutes);
app.use("/api", videoRoutes);
app.use("/api", subscribeRoutes);
app.use("/api", commentRoutes);
app.get("/", (req, res) => {
res.json({ message: "Welcome to DevTube" });
});
const port = process.env.PORT || 1212;
app.listen(port, () => {
console.log(`Server Running at ${port}`);
});