-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.js
28 lines (24 loc) · 813 Bytes
/
app.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
const express = require('express');
var cors = require('cors');
const mongoose = require('mongoose');
const routes = require('./routes/index');
const port = process.env.PORT||2022;
const host = '0.0.0.0';
const app = express();
app.use(cors());
app.use(express.json());
app.all('/*', function (req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
next();
});
app.use('/', routes);
mongoose.connect("mongodb+srv://newUser:[email protected]/zomato_march?retryWrites=true&w=majority", {
useUnifiedTopology: true, useNewUrlParser: true
})
.then(() => {
app.listen(port, host, () => {
console.log(`server running at ${host}:${port}`)
});
})
.catch()