-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
45 lines (39 loc) · 1014 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
42
43
44
45
const express = require("express");
const cors = require("cors");
const morgan = require("morgan");
const dotenv = require("dotenv");
const colors = require("colors");
const connectDb = require("./config/connectDb");
//config dot env file
dotenv.config()
//database call
connectDb();
//rest object
const app = express();
// const https = require('https');
// const agent = new https.Agent({
// rejectUnauthorized: false
// });
//middlewares
app.use(cors());
app.use(express.json());
app.use(cors());
//routes
app.use('/api/v1/users', require('./routes/userRoute'))
// app.use('/api/v1', createProxyMiddleware({
// target: 'https://localhost:8080',
// changeOrigin: true,
// agent,
// pathRewrite: {
// [`^/api/v1`]: '',
// },
// router: {
// // add your route and the corresponding target here
// }
// }, require('./routes/userRoute')));
//port
const PORT = 8080 || process.env.PORT;
//listen server
app.listen(PORT, () => {
console.log(`Server running on port ${PORT}`);
});