Use redis session store

This commit is contained in:
Evert Prants 2019-10-23 11:38:14 +03:00
parent 8cbf946715
commit 4dd14bb624
Signed by: evert
GPG Key ID: 1688DA83D222D0B5
3 changed files with 11 additions and 0 deletions

5
app.js
View File

@ -9,9 +9,12 @@ const path = require('path')
const toml = require('toml') const toml = require('toml')
const fs = require('fs') const fs = require('fs')
const uuid = require('uuid/v4') const uuid = require('uuid/v4')
const connectSession = require('connect-redis')
require('express-async-errors') require('express-async-errors')
const SessionStore = connectSession(session)
const util = require('util') const util = require('util')
const get = util.promisify(request.get) const get = util.promisify(request.get)
const post = util.promisify(request.post) const post = util.promisify(request.post)
@ -91,9 +94,11 @@ nunjucks.configure('templates', {
}) })
app.use(session({ app.use(session({
key: 'Streamserver Session',
secret: config['Streaming']['Secret'], secret: config['Streaming']['Secret'],
resave: false, resave: false,
saveUninitialized: true, saveUninitialized: true,
store: new SessionStore(),
cookie: { cookie: {
secure: !dev, secure: !dev,
maxAge: 2678400000 // 1 month maxAge: 2678400000 // 1 month

5
package-lock.json generated
View File

@ -1190,6 +1190,11 @@
"xdg-basedir": "^3.0.0" "xdg-basedir": "^3.0.0"
} }
}, },
"connect-redis": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/connect-redis/-/connect-redis-4.0.3.tgz",
"integrity": "sha512-Php0P0ShNfilW6f2d/2v7Q0VAiFeBYsg0bIgu8ST3x26CcQ1JtzV6vxPLUwK0uiq10hQSMR+HzSNhWbcvx6nLg=="
},
"console-browserify": { "console-browserify": {
"version": "1.1.0", "version": "1.1.0",
"resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz", "resolved": "https://registry.npmjs.org/console-browserify/-/console-browserify-1.1.0.tgz",

View File

@ -21,6 +21,7 @@
}, },
"dependencies": { "dependencies": {
"body-parser": "^1.18.3", "body-parser": "^1.18.3",
"connect-redis": "^4.0.3",
"ejs": "^2.6.1", "ejs": "^2.6.1",
"express": "^4.16.4", "express": "^4.16.4",
"express-async-errors": "^3.1.1", "express-async-errors": "^3.1.1",