-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
35 lines (27 loc) · 679 Bytes
/
server.js
File metadata and controls
35 lines (27 loc) · 679 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
import express from "express";
import colors from "colors";
import dotenv from "dotenv";
import morgan from "morgan";
import connectDB from "./config/db.js";
import authRoutes from "./routes/authRoute.js";
// Config dotenv
dotenv.config();
// Database Config
connectDB();
// Rest Object
const app = express();
// Middlewares
app.use(express.json());
app.use(morgan("dev"));
// Routes
app.use("/api/v1/auth", authRoutes);
// Rest API
app.get("/", (req, res) => {
res.send("<h1>Welcome to Ecommerce</h1>");
});
// Port
const PORT = process.env.PORT || 8000;
// Listen
app.listen(PORT, () => {
console.log(`Server Running on http://localhost:${PORT}`.bgCyan.white);
});