-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
42 lines (37 loc) · 1.18 KB
/
Copy pathindex.js
File metadata and controls
42 lines (37 loc) · 1.18 KB
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
import cors from "cors";
import dotenv from "dotenv";
import express from "express";
import cookieParser from "cookie-parser";
import connectDB from "./config/db.js";
import authRoutes from "./routes/auth.js";
import bookRoutes from "./routes/books.js";
import reviewRoutes from "./routes/review.js";
import shelfRoutes from "./routes/shelf.js";
import recommendationRoutes from "./routes/recommendationRoutes.js";
import videoRoutes from "./routes/video.js";
import userRoutes from "./routes/users.js";
dotenv.config();
const PORT = process.env.PORT || 5000;
const app = express();
app.use(
cors({
origin: ["http://localhost:3000", "https://book-worm-tracker.vercel.app"],
credentials: true,
}),
);
app.use(express.json());
app.use(cookieParser());
await connectDB();
app.use("/api/auth", authRoutes);
app.use("/api/books", bookRoutes);
app.use("/api/review", reviewRoutes);
app.use("/api/shelf", shelfRoutes);
app.use("/api/recommendations", recommendationRoutes);
app.use("/api", videoRoutes);
app.use("/api", userRoutes);
app.get("/", (req, res) => {
res.send("bookworm server is running successfully...");
});
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});