-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
42 lines (34 loc) · 1.06 KB
/
app.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 http = require('http')
const session = require('express-session')
const SequelizeStore = require('connect-session-sequelize')(session.Store)
const app = express()
const models = require('./app/models')
const server = http.createServer(app)
models.sequelize.sync().then(() => {
server.listen(process.env.PORT || 5000)
})
/* For generating session */
let myStore = new SequelizeStore({
db: models.sequelize,
checkExpirationInterval: 15 * 60 * 1000, // The interval at which to cleanup expired sessions in milliseconds.
expiration: 24 * 60 * 60 * 1000 // The maximum age (in milliseconds) of a valid session.
})
app.use(
session({
key: 'user_sid',
secret: 'secretkey',
store: myStore,
resave: false,
proxy: true
})
)
myStore.sync()
// app.set('port', process.env.PORT || 5000)
app.use(express.static(__dirname + '/public'))
app.get('/', function (request, response) {
response.send('Hello World! @ URL /')
})
app.get('/api', function (request, response) {
response.send('Hello World! @ URL /api ')
})