Based on docs, this is how to create a redisstore:
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
app.use(session({
store: new RedisStore(options),...
}));
I am converting them to typescript:
import * as session from 'express-session';
import * as RedisStore from 'connect-redis';
app.use(session({
store: new (RedisStore(session))(options),...
}));
However, I am getting an error. How do you convert this line of code:
var RedisStore = require('connect-redis')(session);
I have figured it out:
import * as session from 'express-session';
import * as connectRedis from 'connect-redis';
let RedisStore = connectRedis(session);
app.use(session({
store: new RedisStore({client: redis.createClient(6379, "localhost")}),...
}));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With