forked from ishita0202/CSI_News
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
33 lines (29 loc) · 861 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
require('dotenv').config();
const express = require('express');
const mongoose = require('mongoose');
const cors = require('cors');
const cookieParser = require('cookie-parser');
const app = express();
app.use(express.json());
app.use(cors());
app.use(cookieParser());
// Router
app.use('/api', require('./routes/authRouter'));
app.use('/api', require('./routes/newsRouter'));
app.use('/api', require('./routes/userRouter'));
app.use('/api', require('./routes/feedbackRouter'));
const URL = process.env.MONGODB_URL;
mongoose.connect(URL, {
useCreateIndex: true,
useFindAndModify: false,
useNewUrlParser: true,
useUnifiedTopology: true
}, err => {
if(err)
throw err;
console.log('Connected to mongodb')
});
const port = process.env.PORT || 5000;
app.listen(port, () => {
console.log('Server is running on port:', port);
})