-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (26 loc) · 942 Bytes
/
Copy pathserver.js
File metadata and controls
37 lines (26 loc) · 942 Bytes
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
import express from "express";
import dotenv from "dotenv";
import cors from "cors";
import helmet from "helmet";
import morgan from "morgan";
import connectDB from "./config/db.js";
import authRoutes from "./routes/authRoutes.js";
import userRoutes from "./routes/userRoutes.js";
import { errorHandler } from "./middleware/errorMiddleware.js";
import productRoutes from "./routes/productRoutes.js";
dotenv.config();
const app = express();
const PORT = process.env.PORT || 3000;
app.use(express.json({ limit: "30mb", extented: true }));
app.use(express.urlencoded({ limit: "30mb", extented: true }));
app.use(morgan("dev"));
await connectDB()
app.use("/api/auth", authRoutes);
app.use("/api/users",userRoutes);
app.use("/api/products",productRoutes);
app.use(errorHandler);
app.listen(PORT, () => {
console.log(
`process ID ${process.pid}:server running on http://localhost:${PORT}/ in ${process.env.NODE_ENV} mode`
);
});