Instantiate under ES6/Module
BarryCarlyon opened this issue · comments
Barry Carlyon commented
What would be the correct way to instantiate connect-redis via import ie as ES6/module.
I'm trying to do things the "new" way, and I've having fun getting ConnectRedis to instantiate.
This is something to also potentially add to the documentation
Micael Levi L. Cavalcante commented
nothing special
import session from 'express-session'
import connectRedis from 'connect-redis'
const RedisStore = connectRedis(session)
Barry Carlyon commented
Oh lawdy.
I think I tried that at one point and it hiccuped elsewhere.
Solved it:
import express from 'express';
import { createClient } from 'redis';
let redisClient = createClient({ legacyMode: true });
redisClient.connect().catch(console.error);
import session from 'express-session';
import connectRedis from 'connect-redis';
const RedisStore = connectRedis(session)
const serverSession = session({
name: 'whatever',
store: new RedisStore({
client: redisClient
}),
secret: 'dfljkdsakljasdkljkasdlf',
resave: true,
saveUninitialized: true,
cookie: {
secure: true,
httpOnly: false,
domain: 'some.url.net'
},
rolling: true
})
Ta rubber ducks!