-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
41 lines (33 loc) · 945 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
37
38
39
40
41
const express = require("express");
const morgan = require("morgan");
const cors = require("cors");
const bodyParser = require("body-parser");
const colors = require("colors");
const dotenv = require("dotenv");
const connectDB = require("./config/db");
const errorHandler = require("./middelwares/errorMiddleware");
//routes path
const authRoutes = require("./routes/authRoutes");
//dotenv
dotenv.config();
//mongo connection
connectDB();
//rest object
const app = express();
//middlewares
app.use(cors());
app.use(express.json());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(morgan("dev"));
app.use(errorHandler);
const PORT = process.env.PORT || 8080;
//API routes
app.use("/api/v1/auth", authRoutes);
app.use("/api/v1/openai", require("./routes/openaiRoutes"));
//listen server
app.listen(PORT, () => {
console.log(
`Server Running in ${process.env.DEV_MODE} mode on port no ${PORT}`.bgCyan
.white
);
});