38 lines
773 B
JavaScript
38 lines
773 B
JavaScript
'use strict';
|
|
|
|
const session = require('express-session');
|
|
|
|
let redisStore;
|
|
|
|
const config = {
|
|
secret: 'geogeogeogeopoopoopoopoopooooooopPOOOPPPPOOOOOOOOOOOOHNOPOOP;asjldfhaksdjfh',
|
|
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;
|
|
|