-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
37 lines (25 loc) · 790 Bytes
/
index.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
const express = require("express");
const app = express();
const routes = require("./controllers/routes");
const bodyParser = require("body-parser");
const cookieParser = require("cookie-parser");
const cors = require("./middleware/cors");
require("dotenv").config();
const connectToDb = require("./configurations/dbConnection");
const settings = require("./configurations/settings");
const main = () => {
try {
connectToDb();
app.listen(settings.port, () =>
console.log(`<>>> Server is live on port ${settings.port} <<<>`)
);
} catch (error) {
console.log(`!!! DB Error: ${error} !!!`);
}
app.use(cors());
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(routes);
};
main();