@ackplus/nest-auth 1.1.63 → 1.1.65

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -113,6 +113,54 @@ NestAuthModule.forRoot({
113
113
  })
114
114
  ```
115
115
 
116
+ ## Session Storage Options
117
+
118
+ By default, sessions are stored in the database via TypeORM. You can switch to Redis for
119
+ multi-instance performance without changing your login/signup flows.
120
+
121
+ ### Redis Setup
122
+
123
+ 1) Install the optional Redis dependency:
124
+
125
+ ```bash
126
+ npm install ioredis
127
+ ```
128
+
129
+ 2) Enable Redis sessions:
130
+
131
+ ```typescript
132
+ import { SessionStorageType } from '@ackplus/nest-auth';
133
+
134
+ NestAuthModule.forRoot({
135
+ session: {
136
+ storageType: SessionStorageType.REDIS, // or 'redis'
137
+ redis: {
138
+ url: process.env.REDIS_URL, // preferred when available
139
+ host: '127.0.0.1',
140
+ port: 6379,
141
+ password: process.env.REDIS_PASSWORD,
142
+ db: 0,
143
+ tls: undefined,
144
+ keyPrefix: 'nest-auth:sess:',
145
+ ttlSeconds: 60 * 60 * 24 * 7,
146
+ enableOfflineQueue: true,
147
+ },
148
+ },
149
+ });
150
+ ```
151
+
152
+ Notes:
153
+ - If `session.storageType` is omitted, the database store is used (no breaking changes).
154
+ - Legacy config is still supported: `session.redisUrl`.
155
+ - Redis keys are JSON-serialized and use TTL; `ttlSeconds` defaults to the session expiry when possible.
156
+
157
+ ### Production Notes
158
+
159
+ - Enable Redis persistence (AOF/RDB) for durability.
160
+ - Use Redis clustering/sentinel for high availability.
161
+ - Choose a consistent `keyPrefix` to isolate environments.
162
+ - Monitor TTL/evictions and memory usage.
163
+
116
164
  ## Documentation
117
165
 
118
166
  For full documentation covering RBAC, Tenants, and advanced configuration, please refer to the official docs (link to be added).