-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
49 lines (44 loc) · 1.17 KB
/
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
38
39
40
41
42
43
44
45
46
47
48
49
const express = require('express');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser');
const session = require('express-session');
const { verify } = require('jsonwebtoken');
const jwt = require('jsonwebtoken');
const router = require('./routes/index');
const port = 5000 || process.env.PORT;
const flash = require('connect-flash');
const flashMware = require('./config/flash-middleware');
const app = express();
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
//app.use(express.urlencoded({ extended: true }));
app.use(cookieParser());
app.use(
session({
name: 'news_bingo',
secret: 'secretisoutfinally',
resave: false,
saveUninitialized: false,
cookie: {
//secure:true,
httpOnly: true,
maxAge: 20 * 60 * 1000,
},
})
);
app.use(flash());
app.use(flashMware.setflash);
app.use(express.static('./assets'));
// set up the view engine
app.set('view engine', 'ejs');
app.set('views', './views');
//use router
app.use('/', router);
//listening to port
app.listen(port, (err) => {
if (err) {
console.log(err);
} else {
console.log(`server runnin on ${port}`);
}
});