-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
49 lines (35 loc) · 1.18 KB
/
app.js
File metadata and controls
49 lines (35 loc) · 1.18 KB
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 app=express();
const session=require("express-session")
const bodyParser=require("body-parser")
const pgConnect = require('connect-pg-simple');
const helmet = require('helmet');
//use .env file for our process
require('dotenv').config();
/* Init helmet and CORS */
app.use(helmet({contentSecurityPolicy: false,}));
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(session({
// It holds the secret key for session
store:new (pgConnect(session))({ conString: process.env.DATABASE_URL }),
// Forces the session to be saved
// back to the session store
resave: false,
secret: '123456xxx',
// Forces a session that is "uninitialized"
// to be saved to the store
saveUninitialized: false,
cookie: {maxAge:30*3600*24}
}))
/* Define the static files and routes */
app.use('/assets', express.static('assets'));
//app.use(express.static(path.join(__dirname,'/')));
app.use(require('./routes'))
app.get('*', (req, res) => {
res.status(404).render('404');
});
app.listen(5000, function(){
console.log("app is working on port 5000")
})