-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
36 lines (32 loc) · 874 Bytes
/
server.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
import express from "express";
import colors from "colors";
import dotenv from "dotenv";
import morgan from "morgan";
import connectDB from "./config/db.js";
import authoRoutes from "./routes/authRoute.js";
import cors from "cors";
import categoryRoutes from "./routes/categoryRoutes.js";
import productRoutes from "./routes/productRoutes.js";
//env
dotenv.config();
// Express app
const app = express();
//db config
connectDB();
//middleWare
app.use(express.json());
app.use(morgan("dev"));
app.use(cors());
// Route
app.use("/api/v1/auth", authoRoutes);
app.use("/api/v1/category", categoryRoutes);
app.use("/api/v1/product", productRoutes);
app.get("/", (req, res) => {
res.send("<h1>Welcome to Saman</h1>");
});
// Default port
const PORT = process.env.PORT;
// Starting server
app.listen(PORT, () => {
console.log(`Server running on ${PORT}`.bgCyan.white);
});