title: How to use Redis as a store for Express Session NestJS
body: <p>I'm creating an API using NestJS and was trying to set up a session store for my express session but I get an error from this line. I did use express-session with Redis on a new project I created just using express beforehand to understand how Redis and express sessions worked but when I tried porting it over to NestJS it didn't work.</p>
  <p>Main.ts</p>
  <pre><code>import connectRedis from 'connect-redis';
  import { redis } from './redis';
  
  async function bootstrap() {
    const app = await NestFactory.create(AppModule);
    const RedisStore = connectRedis(session);
  </code></pre>
  <p>This is the error I get</p>
  <pre><code>const RedisStore = connectRedis(session);
                                 ^
  TypeError: connect_redis_1.default is not a function
  </code></pre>
  <p>The error occurs before any other redis related feature or express-session is called. I will still include how I set up Redis &amp; Express-Session in case that is needed.</p>
  <p>Redis.ts</p>
  <pre><code>import Redis from 'ioredis';
  
  export const redis = new Redis(
    port,
    'hostName',
    { password: 'password' },
  );
  </code></pre>
  <p>Session Inside of Main.ts</p>
  <pre><code>  app.use(
      session({
        store: new RedisStore({ client: redis }),
        cookie: {
          maxAge: 60000 * 60 * 24,
        },
        secret: 'mysecret',
        saveUninitialized: false,
        resave: false,
      }),
    );
  </code></pre>
  <p>I did read from the NestJS documentation that i can setup Redis as a microservice however i really only need Redis for my Express-Session and dont want to set up the redis microservice if i can get this fixed.</p>
  <p>I also use Mongoose to connect to my MongoDB which i use for my repositories inside of NestJS. Previously in other projects instead of using Redis i would setup my store in TypeORM using ORMSession if anyone has an alternative of this that works with Mongoose then that would also work.</p>
  <pre><code>const sessionRepo = getRepository(TypeORMSession);
  
  ...
  
  store: new TypeormStore().connect(sessionRepo),
  </code></pre>