pomodoro/server/config/session.js
2016-08-14 19:18:09 +02:00

38 lines
798 B
JavaScript

'use strict'
const session = require('express-session')
let redisStore
const config = {
secret: 'asdf1h918798&(*&ijh21kj4hk123j45h2k34jh52k3g45)thisisacompletelyrandomgeneratedstring...whatastrangecoincidence...',
resave: false,
saveUninitialized: true
}
const redisConfig = {
host: 'localhost',
port: 6379
}
if (ENV === 'production') {
const RedisStore = require('connect-redis')(require('express-session'))
redisStore = new RedisStore(redisConfig)
redisStore.on('connect', function () {
console.info('Redis connected succcessfully')
})
redisStore.on('disconnect', function () {
throw new Error('Unable to connect to redis. Has it been started?')
})
config.store = redisStore
} else {
config.store = new session.MemoryStore()
}
module.exports = config