Nestjs Session

screenshot of Nestjs Session
express
nestjs

Idiomatic Session Module for NestJS. Built on top of `express-session`

Overview

This module provides a session implementation for storing data in external stores and passing the session ID to clients via Cookie/Set-Cookie headers. It includes examples for setting up session handling in controllers and emphasizes the importance of not using the provided in-memory store in production environments. The module also offers options for integrating with Redis for more robust data storage.

Features

  • SessionModule.forRoot: Provides static methods for synchronous configuration without dependencies.
  • SessionModule.forRootAsync: Offers static methods for synchronous/asynchronous configuration with dependencies.
  • NestSessionOptions: Interface for specifying session options including session, forRoutes, exclude, retries, and retriesStrategy.
  • NestSessionAsyncOptions: Interface for creating a session module that depends on other modules with properties like imports, inject, and useFactory.
  • Migration to v2: Clarifies the migration process, highlighting that express-session and @types/express-session are now peer dependencies.

Summary

This module offers a convenient way to manage sessions in a NestJS application, providing flexibility for different configurations and external store integrations. By following the installation guide and understanding the available options, developers can enhance their session handling capabilities effectively.

express
Express

Express.js is a simple Node.js framework for single, multi-page, and hybrid web applications.

nestjs
Nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript.

eslint
Eslint

ESLint is a linter for JavaScript that analyzes code to detect and report on potential problems and errors, as well as enforce consistent code style and best practices, helping developers to write cleaner, more maintainable code.

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.