-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
39 lines (31 loc) · 945 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
34
35
36
37
38
39
require("dotenv").config();
const express = require("express");
const cors = require("cors");
const { catalogRoutes } = require("./routes/catalog.routes");
const { productRoutes } = require("./routes/product.routes");
const { messageRoutes } = require("./routes/message.routes");
const app = express();
const PORT = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.get("/", async (req, res) => {
res.send("here is the response");
});
app.get("/hello", async (req, res) => {
res.send("hello");
});
// catalog routes
app.use("/catalogs", catalogRoutes);
// products routes
app.use("/products", productRoutes);
// messages routes
app.use("/messages", messageRoutes);
app.all("*", async (req, res) => {
res.json({
message: "Routes you're looking is not found",
});
});
app.listen(PORT, "0.0.0.0", () => {
console.log(`Server is already running at ${PORT}`);
});