1.0.4 • Published 2 years ago

nestjs-package-express-session-auth v1.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

Installation

npm i nestjs-package-express-session-auth

Usage

// auth.module.ts
@Module({
  imports: [
    ExpressSessionAuthModule.forRootAsync({
      imports: [UserModule],
      useFactory: (authService: UserService): IAuthLoginBaseOptions => {
        const pgSession = connectPgSimple(session);
        return {
          authService,
          session: {
            name: 'sid',
            secret: 'secret',
            rolling: true,
            cookie: {
              maxAge: 60 * 1000,
              secure: process?.env?.NODE_ENV === 'production',
              httpOnly: process?.env?.NODE_ENV === 'production',
            },
            store: new pgSession({
              conString: 'postgresql://user:password@localhost:5432/db?schema=public',
            }),
          },
        };
      },
      inject: [UserService],
    }),
  ]
})

Change Log

See Changelog for more information.