-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
33 lines (28 loc) · 1017 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
const express = require('express');
const app = express();
const db = require('./database');
const checkConfigVariables = require('./checkConfig');
const allRouter = require('./Routes/allRoutes');
const cookieparser = require('cookie-parser');
const cors = require('cors');
const port = 8000;
db(); // checking database connection
// checkConfigVariables(); // checking environment variables
var corsOptions = {
credentials: true,
origin: true
// httponlycookie
// logging
// helmet
// port from env
};
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cookieparser()); // handling cookies in request
app.use(cors(corsOptions)); // handling cors
app.use('', allRouter);
//starting server
app.listen(port, (err) => {
if (err) console.log(err);
else console.log(`Running on port ${port}`);
});