-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
35 lines (30 loc) · 837 Bytes
/
app.js
File metadata and controls
35 lines (30 loc) · 837 Bytes
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
const express = require("express");
const mongoose = require("mongoose");
const config = require("config");
const bodyParser = require("body-parser");
const routes = require("./routes");
const cors = require("cors");
const app = express();
//app.use(cors({ origin: "*" }));
app.use(cors());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(routes);
const PORT = config.get("port");
async function start() {
try {
await mongoose.connect(config.get("mongoURI"), {
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
useFindAndModify: false,
});
app.listen(process.env.PORT || PORT, () =>
console.log(`App is started on port ${PORT}`)
);
} catch (error) {
console.log("error" + error);
process.exit(1);
}
}
start();