-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
29 lines (22 loc) · 641 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
const mongoose = require('mongoose');
const dotenv = require('dotenv');
const cors = require("cors")
dotenv.config({ path: './config.env' });
const app = require('./app');
app.use(cors({
origin:["http://localhost:3000"],
credentials:true
}));
const port = process.env.PORT || 3000;
const server = app.listen(port, () => {
console.log(`App running on port ${port}...`);
});
const URL= process.env.DATABASE;
mongoose
.connect(URL,{
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
useUnifiedTopology: true
})
.then(() => console.log('DB connection successful!'));