2.0.44 • Published 1 year ago

@anchan828/nest-redis-session-express v2.0.44

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@anchan828/nest-redis-session-express

This module is for express.

Install

npm i @anchan828/nest-redis-session-express

The redis package you use:

npm i redis
npm i ioredis
npm i redis-mock

Usage

import { RedisSessionModule } from "@anchan828/nest-redis-session-express";

// redis@v4
import { createClient } from "redis";
const redisClient = createClient({ legacyMode: true });
redisClient.connect().catch(console.error);

// redis@v3
import { createClient } from "redis";
const redisClient = createClient();

// ioredis
import IORedis from "ioredis";
const redisClient = new IORedis();

// redis-mock
import { createClient } from "redis-mock";
const redisClient = createClient();

// ioredis-mock
const IORedisMock = require("ioredis-mock");
const redisClient = new IORedisMock();

@Module({
  imports: [
    RedisSessionModule.register({
      redisClient,
      session: {
        secret: "secret",
        saveUninitialized: false,
        resave: false,
      },
    }),
  ],
})
export class AppModule {}

Trouble-shooting

If it doesn't work, please check the order of middleware.

https://github.com/nestjs/docs.nestjs.com/issues/1248#issuecomment-629400653

@Module({
  imports: [
    RedisSessionModule.register({
      redisClient,
      session: { resave: false, saveUninitialized: false, secret: "secret" },
    }),
    PassportModule.register({ session: true }),
    // Don't change the import order! ☚
    PassportInitializeModule,
  ],
})
export class PassportSessionModule {}

@Module({})
export class PassportInitializeModule implements NestModule {
  public async configure(consumer: MiddlewareConsumer): Promise<void> {
    consumer.apply(passport.initialize(), passport.session()).forRoutes({ method: RequestMethod.ALL, path: "*" });
  }
}
2.0.44

1 year ago

2.0.43

1 year ago

2.0.39

2 years ago

2.0.42

1 year ago

2.0.40

2 years ago

2.0.41

2 years ago

2.0.37

2 years ago

2.0.38

2 years ago

2.0.36

2 years ago

2.0.28

2 years ago

2.0.29

2 years ago

2.0.35

2 years ago

2.0.33

2 years ago

2.0.34

2 years ago

2.0.31

2 years ago

2.0.32

2 years ago

2.0.30

2 years ago

2.0.27

2 years ago

2.0.26

2 years ago

2.0.24

2 years ago

2.0.25

2 years ago

2.0.22

2 years ago

2.0.23

2 years ago

2.0.15

2 years ago

2.0.16

2 years ago

2.0.13

2 years ago

2.0.14

2 years ago

2.0.12

2 years ago

2.0.19

2 years ago

2.0.17

2 years ago

2.0.18

2 years ago

2.0.21

2 years ago

2.0.11

2 years ago

2.0.10

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

0.1.50

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

0.1.49

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

0.1.43

3 years ago

0.1.44

3 years ago

0.1.45

3 years ago

0.1.46

3 years ago

0.1.47

3 years ago

0.1.48

2 years ago

0.1.41

3 years ago

0.1.42

3 years ago

0.1.40

3 years ago

0.1.39

3 years ago

0.1.33

3 years ago

0.1.34

3 years ago

0.1.35

3 years ago

0.1.36

3 years ago

0.1.37

3 years ago

0.1.38

3 years ago

0.1.31

3 years ago

0.1.32

3 years ago

0.1.30

3 years ago

0.1.27

3 years ago

0.1.28

3 years ago

0.1.29

3 years ago

0.1.21

3 years ago

0.1.22

3 years ago

0.1.23

3 years ago

0.1.24

3 years ago

0.1.25

3 years ago

0.1.26

3 years ago

0.1.20

3 years ago

0.1.19

3 years ago

0.1.17

3 years ago

0.1.18

3 years ago

0.1.16

3 years ago

0.1.15

3 years ago

0.1.14

3 years ago

0.1.13

3 years ago

0.1.12

3 years ago

0.1.11

3 years ago

0.1.10

3 years ago

0.1.9

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago