-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
37 lines (29 loc) · 751 Bytes
/
server.js
File metadata and controls
37 lines (29 loc) · 751 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 colors from 'colors';
import dotenv from "dotenv";
import morgan from 'morgan';
import connectDb from './config/db.js';
import authRoutes from './routes/authRoute.js';
import cors from "cors"
// configure env
dotenv.config();
// database config
connectDb();
// rest object
const app = express();
// middlewares
app.use(cors());
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 MERN Stack App </h1>")
})
// Port
const PORT = process.env.PORT || 8080;
// run listen
app.listen(PORT, () => {
console.log(`Server Running On ${process.env.DEV_MODE} mode on port ${PORT}`.bgCyan.white);
})