-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
42 lines (37 loc) · 1.14 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
const express = require('express');
const app = express();
const PORT = process.env.PORT || 8000;
const path = require('path');
const bodyParser = require('body-parser')
const session = require('express-session');
const MemoryStore = require('memorystore')(session)
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended:true}))
const types = require('./routes/types');
const api = require('./routes/api');
const views = require('./routes/views');
const auth = require('./routes/auth');
app.set('trust proxy', 1);
app.use(session({
cookie: { maxAge: 86400000 },
store: new MemoryStore({
checkPeriod: 86400000
}),
secret: 'uid',
resave: false,
saveUninitialized: true,
// cookie: { secure: false }
cookie: { secure: true }
}));
app.use('/', views);
app.use('/auth', auth);
app.use('/api', api);
app.use('/types', types);
app.listen(PORT, () => {
console.log("Server listening on PORT", PORT);
});