forked from Pratishthan/node-blog-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (25 loc) · 969 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
const express = require("express");
const productRouters = require("./src/routes/productRoutes");
const orderRouters = require("./src/routes/orderRoutes");
const userRouters = require("./src/routes/userRoutes");
const paymentRouters = require("./src/routes/paymentRoutes");
const categoryRouters = require("./src/routes/categoryRoutes");
const reviewRouters = require("./src/routes/reviewRoutes");
// loading environment variables
require("dotenv").config();
const app = express();
app.use(express.json());
app.use(express.urlencoded());
const port = process.env.PORT || 3000;
// routers
app.use("/products", productRouters);
app.use("/order", orderRouters);
app.use("/user", userRouters);
app.use("/payment", paymentRouters);
app.use("/category", categoryRouters);
app.use("/product", reviewRouters);
// 404 page
app.get((req, res, next) => {
res.status(404).json({ message: "Not found" });
});
app.listen(port, () => console.log(`Listening on port ${port}`));