@xnestjs/redisess 1.7.1 → 1.8.1
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
|
@@ -24,17 +24,16 @@ import { RedisessModule } from '@xnestjs/redisess';
|
|
|
24
24
|
const client = new Redis();
|
|
25
25
|
|
|
26
26
|
@Module({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
imports: [
|
|
28
|
+
RedisessModule.forRoot({
|
|
29
|
+
useValue: {
|
|
30
|
+
client,
|
|
31
|
+
namespace: 'sessions',
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
],
|
|
35
35
|
})
|
|
36
|
-
export class MyModule {
|
|
37
|
-
}
|
|
36
|
+
export class MyModule {}
|
|
38
37
|
```
|
|
39
38
|
|
|
40
39
|
### Register async
|
|
@@ -49,31 +48,30 @@ import { RedisessModule } from '@xnestjs/redisess';
|
|
|
49
48
|
const client = new Redis();
|
|
50
49
|
|
|
51
50
|
@Module({
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
51
|
+
imports: [
|
|
52
|
+
RedisessModule.forRootAsync({
|
|
53
|
+
inject: [ConfigModule],
|
|
54
|
+
useFactory: (config: ConfigService) => ({
|
|
55
|
+
client,
|
|
56
|
+
namespace: config.get('SESSION_NAMESPACE'),
|
|
57
|
+
}),
|
|
58
|
+
}),
|
|
59
|
+
],
|
|
61
60
|
})
|
|
62
|
-
export class MyModule {
|
|
63
|
-
}
|
|
61
|
+
export class MyModule {}
|
|
64
62
|
```
|
|
65
63
|
|
|
66
64
|
## Environment Variables
|
|
67
65
|
|
|
68
66
|
The library supports configuration through environment variables. Environment variables below is accepted.
|
|
69
|
-
All environment variables starts with prefix (
|
|
67
|
+
All environment variables starts with prefix (RMQ\_). This can be configured while registering the module.
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
<!--- BEGIN env --->
|
|
72
70
|
|
|
73
71
|
| Environment Variable | Type | Default | Description |
|
|
74
|
-
|
|
72
|
+
| --------------------- | ------ | ------- | ---------------------------------- |
|
|
75
73
|
| SESSION_NAMESPACE | String | | |
|
|
76
74
|
| SESSION_TTL | Number | 1800 | Time-To-Live value in seconds |
|
|
77
75
|
| SESSION_WIPE_INTERVAL | Number | 5000 | Interval in ms to run wipe process |
|
|
78
76
|
|
|
79
|
-
|
|
77
|
+
<!--- END env --->
|
|
@@ -10,6 +10,7 @@ function getRedisessConfig(moduleOptions, prefix = 'SESSION_') {
|
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
options.namespace = options.namespace ?? env[prefix + 'NAMESPACE'];
|
|
12
12
|
options.ttl = options.ttl ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'TTL']);
|
|
13
|
-
options.wipeInterval =
|
|
13
|
+
options.wipeInterval =
|
|
14
|
+
options.wipeInterval ?? (0, putil_varhelpers_1.toInt)(env[prefix + 'WIPE_INTERVAL']) ?? 5000;
|
|
14
15
|
return options;
|
|
15
16
|
}
|
|
@@ -53,7 +53,9 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
|
|
|
53
53
|
provide: token,
|
|
54
54
|
inject: [constants_js_1.REDISESS_SESSION_OPTIONS],
|
|
55
55
|
useFactory: async (sessionOptions) => {
|
|
56
|
-
const redisessOptions = (0, objects_1.omit)(sessionOptions, [
|
|
56
|
+
const redisessOptions = (0, objects_1.omit)(sessionOptions, [
|
|
57
|
+
'client',
|
|
58
|
+
]);
|
|
57
59
|
return new redisess_1.SessionManager(sessionOptions.client, redisessOptions);
|
|
58
60
|
},
|
|
59
61
|
},
|
|
@@ -63,7 +65,9 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
|
|
|
63
65
|
},
|
|
64
66
|
{
|
|
65
67
|
provide: common_1.Logger,
|
|
66
|
-
useValue: typeof opts.logger === 'string'
|
|
68
|
+
useValue: typeof opts.logger === 'string'
|
|
69
|
+
? new common_1.Logger(opts.logger)
|
|
70
|
+
: opts.logger,
|
|
67
71
|
},
|
|
68
72
|
];
|
|
69
73
|
return {
|
|
@@ -6,6 +6,7 @@ export function getRedisessConfig(moduleOptions, prefix = 'SESSION_') {
|
|
|
6
6
|
const env = process.env;
|
|
7
7
|
options.namespace = options.namespace ?? env[prefix + 'NAMESPACE'];
|
|
8
8
|
options.ttl = options.ttl ?? toInt(env[prefix + 'TTL']);
|
|
9
|
-
options.wipeInterval =
|
|
9
|
+
options.wipeInterval =
|
|
10
|
+
options.wipeInterval ?? toInt(env[prefix + 'WIPE_INTERVAL']) ?? 5000;
|
|
10
11
|
return options;
|
|
11
12
|
}
|
|
@@ -2,7 +2,7 @@ var RedisessCoreModule_1;
|
|
|
2
2
|
import { __decorate, __metadata, __param } from "tslib";
|
|
3
3
|
import * as assert from 'node:assert';
|
|
4
4
|
import { omit } from '@jsopen/objects';
|
|
5
|
-
import { Inject, Logger } from '@nestjs/common';
|
|
5
|
+
import { Inject, Logger, } from '@nestjs/common';
|
|
6
6
|
import * as crypto from 'crypto';
|
|
7
7
|
import { SessionManager } from 'redisess';
|
|
8
8
|
import { REDISESS_MODULE_ID, REDISESS_SESSION_OPTIONS } from './constants.js';
|
|
@@ -50,7 +50,9 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
|
|
|
50
50
|
provide: token,
|
|
51
51
|
inject: [REDISESS_SESSION_OPTIONS],
|
|
52
52
|
useFactory: async (sessionOptions) => {
|
|
53
|
-
const redisessOptions = omit(sessionOptions, [
|
|
53
|
+
const redisessOptions = omit(sessionOptions, [
|
|
54
|
+
'client',
|
|
55
|
+
]);
|
|
54
56
|
return new SessionManager(sessionOptions.client, redisessOptions);
|
|
55
57
|
},
|
|
56
58
|
},
|
|
@@ -60,7 +62,9 @@ let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
|
|
|
60
62
|
},
|
|
61
63
|
{
|
|
62
64
|
provide: Logger,
|
|
63
|
-
useValue: typeof opts.logger === 'string'
|
|
65
|
+
useValue: typeof opts.logger === 'string'
|
|
66
|
+
? new Logger(opts.logger)
|
|
67
|
+
: opts.logger,
|
|
64
68
|
},
|
|
65
69
|
];
|
|
66
70
|
return {
|