-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
53 lines (45 loc) · 1.9 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
53
require("dotenv").config();
const port = process.env.PORT || 3000;
const express = require("express");
const app = express();
const cors = require("cors");
const mongoose = require("mongoose");
app.use(cors());
app.use(express.json());
const databaseConnection = require("./database/dbConnect");
databaseConnection();
const userRouter = require("./routers/user.router");
const productRouter = require("./routers/product.router");
const cartRouter = require("./routers/cart.router");
const wishlistRouter = require("./routers/wishlist.router");
const addressRouter = require("./routers/address.router");
const videoRouter = require("./routers/video.router");
const likedVideoRouter = require("./routers/likedVideo.router");
const historyRouter = require("./routers/history.router");
const playlistRouter = require("./routers/playlist.router");
const noteRouter = require("./routers/note.router");
const postRouter = require("./routers/post.router");
const notificationRouter = require("./routers/notification.router");
const errorHandler = require("./middlewares/errorHandler");
const routeHandler = require("./middlewares/routeHandler");
const authenticate = require("./middlewares/authenticate");
app.get("/", (req, res) => {
res.send("Welcome to api-supminn");
});
app.use("/users", userRouter);
app.use("/products", productRouter);
app.use("/videos", videoRouter);
app.use("/wishlist", authenticate, wishlistRouter);
app.use("/cart", authenticate, cartRouter);
app.use("/address", authenticate, addressRouter);
app.use("/history", authenticate, historyRouter);
app.use("/liked-video", authenticate, likedVideoRouter);
app.use("/playlist", authenticate, playlistRouter);
app.use("/note", authenticate, noteRouter);
app.use("/post", authenticate, postRouter);
app.use("/notify", authenticate, notificationRouter);
app.use(routeHandler);
app.use(errorHandler);
app.listen(port, () => {
console.log("server started on port:", port);
});