@xnestjs/redisess 1.2.4 → 1.3.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
@@ -1,3 +1,65 @@
1
1
  # @xnestjs/redisess
2
2
 
3
- NestJS extension library for redisess
3
+ NestJS extension library for Redisess
4
+
5
+
6
+ ## Install
7
+
8
+ ```sh
9
+ npm install @xnestjs/redisess
10
+ # or using yarn
11
+ yarn add @xnestjs/redisess
12
+ ```
13
+
14
+ ## Usage
15
+
16
+ ### Register sync
17
+
18
+ An example of nestjs module that import the @xnestjs/mongodb
19
+
20
+ ```ts
21
+ // module.ts
22
+ import { Module } from '@nestjs/common';
23
+ import { RedisessModule } from '@xnestjs/redisess';
24
+
25
+ const client = new Redis();
26
+
27
+ @Module({
28
+ imports: [
29
+ RedisessModule.forRoot({
30
+ useValue: {
31
+ client,
32
+ namespace: 'sessions',
33
+ },
34
+ }),
35
+ ],
36
+ })
37
+ export class MyModule {
38
+ }
39
+ ```
40
+
41
+ ### Register async
42
+
43
+ An example of nestjs module that import the @xnestjs/mongodb async
44
+
45
+ ```ts
46
+ // module.ts
47
+ import { Module } from '@nestjs/common';
48
+ import { RedisessModule } from '@xnestjs/redisess';
49
+
50
+ const client = new Redis();
51
+
52
+ @Module({
53
+ imports: [
54
+ RedisessModule.forRootAsync({
55
+ inject: [ConfigModule],
56
+ useFactory: (config: ConfigService) => ({
57
+ client,
58
+ namespace: config.get('SESSION_NAMESPACE'),
59
+ }),
60
+ }),
61
+ ]
62
+ })
63
+ export class MyModule {
64
+ }
65
+ ```
package/cjs/constants.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REDISESS_MODULE_TOKEN = exports.REDISESS_MODULE_OPTIONS = void 0;
4
- exports.REDISESS_MODULE_OPTIONS = Symbol('REDISESS_MODULE_OPTIONS');
5
- exports.REDISESS_MODULE_TOKEN = Symbol('REDISESS_MODULE_ID');
3
+ exports.REDISESS_MODULE_ID = exports.REDISESS_SESSION_OPTIONS = void 0;
4
+ exports.REDISESS_SESSION_OPTIONS = Symbol('REDISESS_SESSION_OPTIONS');
5
+ exports.REDISESS_MODULE_ID = Symbol('REDISESS_MODULE_ID');
package/cjs/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./constants.js"), exports);
5
- tslib_1.__exportStar(require("./decorators/inject-session-manager.decorators.js"), exports);
6
- tslib_1.__exportStar(require("./interfaces/module-options.interface.js"), exports);
7
5
  tslib_1.__exportStar(require("./redisess.module.js"), exports);
8
- tslib_1.__exportStar(require("./utils/get-session-manager-token.util.js"), exports);
6
+ tslib_1.__exportStar(require("./types.js"), exports);
7
+ tslib_1.__exportStar(require("redisess"), exports);
@@ -3,107 +3,91 @@ var RedisessCoreModule_1;
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.RedisessCoreModule = void 0;
5
5
  const tslib_1 = require("tslib");
6
+ const assert = tslib_1.__importStar(require("node:assert"));
7
+ const objects_1 = require("@jsopen/objects");
6
8
  const common_1 = require("@nestjs/common");
7
- const core_1 = require("@nestjs/core");
8
9
  const crypto = tslib_1.__importStar(require("crypto"));
9
10
  const redisess_1 = require("redisess");
10
11
  const constants_js_1 = require("./constants.js");
11
- const get_session_manager_token_util_js_1 = require("./utils/get-session-manager-token.util.js");
12
+ const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
12
13
  let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
13
- constructor(options, moduleRef) {
14
- this.options = options;
15
- this.moduleRef = moduleRef;
16
- }
17
- static forRoot(options) {
18
- const optionsProvider = {
19
- provide: constants_js_1.REDISESS_MODULE_OPTIONS,
20
- useValue: options,
21
- };
22
- const connectionProvider = {
23
- provide: (0, get_session_manager_token_util_js_1.getSessionManagerToken)(options.name),
24
- useFactory: () => this.createSessionManager(options),
25
- };
26
- return {
27
- module: RedisessCoreModule_1,
28
- providers: [connectionProvider, optionsProvider],
29
- exports: [connectionProvider],
30
- };
14
+ /**
15
+ * Configures and returns a dynamic module
16
+ */
17
+ static forRoot(moduleOptions) {
18
+ return this._createDynamicModule(moduleOptions, {
19
+ global: moduleOptions.global,
20
+ providers: [
21
+ {
22
+ provide: constants_js_1.REDISESS_SESSION_OPTIONS,
23
+ useValue: moduleOptions.useValue,
24
+ },
25
+ ],
26
+ });
31
27
  }
28
+ /**
29
+ * Configures and returns an async dynamic module
30
+ */
32
31
  static forRootAsync(asyncOptions) {
33
- const connectionProvider = {
34
- provide: (0, get_session_manager_token_util_js_1.getSessionManagerToken)(asyncOptions.name),
35
- inject: [constants_js_1.REDISESS_MODULE_OPTIONS],
36
- useFactory: async (oOptions) => {
37
- const name = asyncOptions.name || oOptions.name;
38
- return this.createSessionManager({
39
- ...oOptions,
40
- name,
41
- });
32
+ assert.ok(asyncOptions.useFactory, 'useFactory is required');
33
+ return this._createDynamicModule(asyncOptions, {
34
+ global: asyncOptions.global,
35
+ providers: [
36
+ {
37
+ provide: constants_js_1.REDISESS_SESSION_OPTIONS,
38
+ inject: asyncOptions.inject,
39
+ useFactory: asyncOptions.useFactory,
40
+ },
41
+ ],
42
+ });
43
+ }
44
+ static _createDynamicModule(opts, metadata) {
45
+ const token = opts.token ?? redisess_1.SessionManager;
46
+ const providers = [
47
+ {
48
+ provide: token,
49
+ inject: [constants_js_1.REDISESS_SESSION_OPTIONS],
50
+ useFactory: async (sessionOptions) => {
51
+ const redisessOptions = (0, objects_1.omit)(sessionOptions, ['client']);
52
+ return new redisess_1.SessionManager(sessionOptions.client, redisessOptions);
53
+ },
42
54
  },
43
- };
44
- const asyncProviders = this.createAsyncProviders(asyncOptions);
55
+ {
56
+ provide: CLIENT_TOKEN,
57
+ useExisting: token,
58
+ },
59
+ {
60
+ provide: common_1.Logger,
61
+ useValue: typeof opts.logger === 'string' ? new common_1.Logger(opts.logger) : opts.logger,
62
+ },
63
+ ];
45
64
  return {
46
65
  module: RedisessCoreModule_1,
47
- imports: asyncOptions.imports,
66
+ ...metadata,
48
67
  providers: [
49
- ...asyncProviders,
50
- connectionProvider,
68
+ ...(metadata.providers ?? []),
69
+ ...providers,
51
70
  {
52
- provide: constants_js_1.REDISESS_MODULE_TOKEN,
71
+ provide: constants_js_1.REDISESS_MODULE_ID,
53
72
  useValue: crypto.randomUUID(),
54
73
  },
55
74
  ],
56
- exports: [connectionProvider],
75
+ exports: [constants_js_1.REDISESS_SESSION_OPTIONS, token, ...(metadata.exports ?? [])],
57
76
  };
58
77
  }
59
- async onApplicationShutdown() {
60
- const sessionManager = this.moduleRef.get((0, get_session_manager_token_util_js_1.getSessionManagerToken)(this.options.name));
61
- if (sessionManager)
62
- sessionManager.quit();
63
- }
64
- static createAsyncProviders(asyncOptions) {
65
- if (asyncOptions.useExisting || asyncOptions.useFactory)
66
- return [this.createAsyncOptionsProvider(asyncOptions)];
67
- if (asyncOptions.useClass) {
68
- return [
69
- this.createAsyncOptionsProvider(asyncOptions),
70
- {
71
- provide: asyncOptions.useClass,
72
- useClass: asyncOptions.useClass,
73
- },
74
- ];
75
- }
76
- throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
77
- }
78
- static createAsyncOptionsProvider(asyncOptions) {
79
- if (asyncOptions.useFactory) {
80
- return {
81
- provide: constants_js_1.REDISESS_MODULE_OPTIONS,
82
- useFactory: asyncOptions.useFactory,
83
- inject: asyncOptions.inject || [],
84
- };
85
- }
86
- const useClass = asyncOptions.useClass || asyncOptions.useExisting;
87
- if (useClass) {
88
- return {
89
- provide: constants_js_1.REDISESS_MODULE_OPTIONS,
90
- useFactory: (optionsFactory) => optionsFactory.createOptions(asyncOptions.name),
91
- inject: [useClass],
92
- };
93
- }
94
- throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
78
+ /**
79
+ *
80
+ * @constructor
81
+ */
82
+ constructor(sessionManager) {
83
+ this.sessionManager = sessionManager;
95
84
  }
96
- static async createSessionManager(options) {
97
- const opts = { ...options };
98
- delete opts.client;
99
- delete opts.name;
100
- return new redisess_1.SessionManager(options.client, opts);
85
+ async onApplicationShutdown() {
86
+ this.sessionManager.quit();
101
87
  }
102
88
  };
103
89
  exports.RedisessCoreModule = RedisessCoreModule;
104
90
  exports.RedisessCoreModule = RedisessCoreModule = RedisessCoreModule_1 = tslib_1.__decorate([
105
- (0, common_1.Global)(),
106
- (0, common_1.Module)({}),
107
- tslib_1.__param(0, (0, common_1.Inject)(constants_js_1.REDISESS_MODULE_OPTIONS)),
108
- tslib_1.__metadata("design:paramtypes", [Object, core_1.ModuleRef])
91
+ tslib_1.__param(0, (0, common_1.Inject)(CLIENT_TOKEN)),
92
+ tslib_1.__metadata("design:paramtypes", [redisess_1.SessionManager])
109
93
  ], RedisessCoreModule);
package/esm/constants.js CHANGED
@@ -1,2 +1,2 @@
1
- export const REDISESS_MODULE_OPTIONS = Symbol('REDISESS_MODULE_OPTIONS');
2
- export const REDISESS_MODULE_TOKEN = Symbol('REDISESS_MODULE_ID');
1
+ export const REDISESS_SESSION_OPTIONS = Symbol('REDISESS_SESSION_OPTIONS');
2
+ export const REDISESS_MODULE_ID = Symbol('REDISESS_MODULE_ID');
package/esm/index.js CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './constants.js';
2
- export * from './decorators/inject-session-manager.decorators.js';
3
- export * from './interfaces/module-options.interface.js';
4
2
  export * from './redisess.module.js';
5
- export * from './utils/get-session-manager-token.util.js';
3
+ export * from './types.js';
4
+ export * from 'redisess';
@@ -1,106 +1,90 @@
1
1
  var RedisessCoreModule_1;
2
2
  import { __decorate, __metadata, __param } from "tslib";
3
- import { Global, Inject, Module } from '@nestjs/common';
4
- import { ModuleRef } from '@nestjs/core';
3
+ import * as assert from 'node:assert';
4
+ import { omit } from '@jsopen/objects';
5
+ import { Inject, Logger } from '@nestjs/common';
5
6
  import * as crypto from 'crypto';
6
7
  import { SessionManager } from 'redisess';
7
- import { REDISESS_MODULE_OPTIONS, REDISESS_MODULE_TOKEN } from './constants.js';
8
- import { getSessionManagerToken } from './utils/get-session-manager-token.util.js';
8
+ import { REDISESS_MODULE_ID, REDISESS_SESSION_OPTIONS } from './constants.js';
9
+ const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
9
10
  let RedisessCoreModule = RedisessCoreModule_1 = class RedisessCoreModule {
10
- constructor(options, moduleRef) {
11
- this.options = options;
12
- this.moduleRef = moduleRef;
13
- }
14
- static forRoot(options) {
15
- const optionsProvider = {
16
- provide: REDISESS_MODULE_OPTIONS,
17
- useValue: options,
18
- };
19
- const connectionProvider = {
20
- provide: getSessionManagerToken(options.name),
21
- useFactory: () => this.createSessionManager(options),
22
- };
23
- return {
24
- module: RedisessCoreModule_1,
25
- providers: [connectionProvider, optionsProvider],
26
- exports: [connectionProvider],
27
- };
11
+ /**
12
+ * Configures and returns a dynamic module
13
+ */
14
+ static forRoot(moduleOptions) {
15
+ return this._createDynamicModule(moduleOptions, {
16
+ global: moduleOptions.global,
17
+ providers: [
18
+ {
19
+ provide: REDISESS_SESSION_OPTIONS,
20
+ useValue: moduleOptions.useValue,
21
+ },
22
+ ],
23
+ });
28
24
  }
25
+ /**
26
+ * Configures and returns an async dynamic module
27
+ */
29
28
  static forRootAsync(asyncOptions) {
30
- const connectionProvider = {
31
- provide: getSessionManagerToken(asyncOptions.name),
32
- inject: [REDISESS_MODULE_OPTIONS],
33
- useFactory: async (oOptions) => {
34
- const name = asyncOptions.name || oOptions.name;
35
- return this.createSessionManager({
36
- ...oOptions,
37
- name,
38
- });
29
+ assert.ok(asyncOptions.useFactory, 'useFactory is required');
30
+ return this._createDynamicModule(asyncOptions, {
31
+ global: asyncOptions.global,
32
+ providers: [
33
+ {
34
+ provide: REDISESS_SESSION_OPTIONS,
35
+ inject: asyncOptions.inject,
36
+ useFactory: asyncOptions.useFactory,
37
+ },
38
+ ],
39
+ });
40
+ }
41
+ static _createDynamicModule(opts, metadata) {
42
+ const token = opts.token ?? SessionManager;
43
+ const providers = [
44
+ {
45
+ provide: token,
46
+ inject: [REDISESS_SESSION_OPTIONS],
47
+ useFactory: async (sessionOptions) => {
48
+ const redisessOptions = omit(sessionOptions, ['client']);
49
+ return new SessionManager(sessionOptions.client, redisessOptions);
50
+ },
39
51
  },
40
- };
41
- const asyncProviders = this.createAsyncProviders(asyncOptions);
52
+ {
53
+ provide: CLIENT_TOKEN,
54
+ useExisting: token,
55
+ },
56
+ {
57
+ provide: Logger,
58
+ useValue: typeof opts.logger === 'string' ? new Logger(opts.logger) : opts.logger,
59
+ },
60
+ ];
42
61
  return {
43
62
  module: RedisessCoreModule_1,
44
- imports: asyncOptions.imports,
63
+ ...metadata,
45
64
  providers: [
46
- ...asyncProviders,
47
- connectionProvider,
65
+ ...(metadata.providers ?? []),
66
+ ...providers,
48
67
  {
49
- provide: REDISESS_MODULE_TOKEN,
68
+ provide: REDISESS_MODULE_ID,
50
69
  useValue: crypto.randomUUID(),
51
70
  },
52
71
  ],
53
- exports: [connectionProvider],
72
+ exports: [REDISESS_SESSION_OPTIONS, token, ...(metadata.exports ?? [])],
54
73
  };
55
74
  }
56
- async onApplicationShutdown() {
57
- const sessionManager = this.moduleRef.get(getSessionManagerToken(this.options.name));
58
- if (sessionManager)
59
- sessionManager.quit();
60
- }
61
- static createAsyncProviders(asyncOptions) {
62
- if (asyncOptions.useExisting || asyncOptions.useFactory)
63
- return [this.createAsyncOptionsProvider(asyncOptions)];
64
- if (asyncOptions.useClass) {
65
- return [
66
- this.createAsyncOptionsProvider(asyncOptions),
67
- {
68
- provide: asyncOptions.useClass,
69
- useClass: asyncOptions.useClass,
70
- },
71
- ];
72
- }
73
- throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
74
- }
75
- static createAsyncOptionsProvider(asyncOptions) {
76
- if (asyncOptions.useFactory) {
77
- return {
78
- provide: REDISESS_MODULE_OPTIONS,
79
- useFactory: asyncOptions.useFactory,
80
- inject: asyncOptions.inject || [],
81
- };
82
- }
83
- const useClass = asyncOptions.useClass || asyncOptions.useExisting;
84
- if (useClass) {
85
- return {
86
- provide: REDISESS_MODULE_OPTIONS,
87
- useFactory: (optionsFactory) => optionsFactory.createOptions(asyncOptions.name),
88
- inject: [useClass],
89
- };
90
- }
91
- throw new Error('Invalid configuration. Must provide useFactory, useClass or useExisting');
75
+ /**
76
+ *
77
+ * @constructor
78
+ */
79
+ constructor(sessionManager) {
80
+ this.sessionManager = sessionManager;
92
81
  }
93
- static async createSessionManager(options) {
94
- const opts = { ...options };
95
- delete opts.client;
96
- delete opts.name;
97
- return new SessionManager(options.client, opts);
82
+ async onApplicationShutdown() {
83
+ this.sessionManager.quit();
98
84
  }
99
85
  };
100
86
  RedisessCoreModule = RedisessCoreModule_1 = __decorate([
101
- Global(),
102
- Module({}),
103
- __param(0, Inject(REDISESS_MODULE_OPTIONS)),
104
- __metadata("design:paramtypes", [Object, ModuleRef])
87
+ __param(0, Inject(CLIENT_TOKEN)),
88
+ __metadata("design:paramtypes", [SessionManager])
105
89
  ], RedisessCoreModule);
106
90
  export { RedisessCoreModule };
package/package.json CHANGED
@@ -1,10 +1,13 @@
1
1
  {
2
2
  "name": "@xnestjs/redisess",
3
- "version": "1.2.4",
3
+ "version": "1.3.1",
4
4
  "description": "NestJS extension library for redisess",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {
8
+ "@jsopen/objects": "^1.5.2",
9
+ "ansi-colors": "^4.1.3",
10
+ "putil-varhelpers": "^1.6.5",
8
11
  "tslib": "^2.8.1"
9
12
  },
10
13
  "peerDependencies": {
@@ -1,2 +1,2 @@
1
- export declare const REDISESS_MODULE_OPTIONS: unique symbol;
2
- export declare const REDISESS_MODULE_TOKEN: unique symbol;
1
+ export declare const REDISESS_SESSION_OPTIONS: unique symbol;
2
+ export declare const REDISESS_MODULE_ID: unique symbol;
package/types/index.d.cts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './constants.js';
2
- export * from './decorators/inject-session-manager.decorators.js';
3
- export * from './interfaces/module-options.interface.js';
4
2
  export * from './redisess.module.js';
5
- export * from './utils/get-session-manager-token.util.js';
3
+ export * from './types.js';
4
+ export * from 'redisess';
package/types/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './constants.js';
2
- export * from './decorators/inject-session-manager.decorators.js';
3
- export * from './interfaces/module-options.interface.js';
4
2
  export * from './redisess.module.js';
5
- export * from './utils/get-session-manager-token.util.js';
3
+ export * from './types.js';
4
+ export * from 'redisess';
@@ -1,14 +1,21 @@
1
1
  import { DynamicModule, OnApplicationShutdown } from '@nestjs/common';
2
- import { ModuleRef } from '@nestjs/core';
3
- import { RedisessModuleAsyncOptions, type RedisessModuleOptions } from './interfaces/module-options.interface.js';
2
+ import { SessionManager } from 'redisess';
3
+ import type { RedisessModuleAsyncOptions, RedisessModuleOptions } from './types.js';
4
4
  export declare class RedisessCoreModule implements OnApplicationShutdown {
5
- private readonly options;
6
- private readonly moduleRef;
7
- constructor(options: RedisessModuleOptions, moduleRef: ModuleRef);
8
- static forRoot(options: RedisessModuleOptions): DynamicModule;
5
+ private readonly sessionManager;
6
+ /**
7
+ * Configures and returns a dynamic module
8
+ */
9
+ static forRoot(moduleOptions: RedisessModuleOptions): DynamicModule;
10
+ /**
11
+ * Configures and returns an async dynamic module
12
+ */
9
13
  static forRootAsync(asyncOptions: RedisessModuleAsyncOptions): DynamicModule;
14
+ private static _createDynamicModule;
15
+ /**
16
+ *
17
+ * @constructor
18
+ */
19
+ constructor(sessionManager: SessionManager);
10
20
  onApplicationShutdown(): Promise<void>;
11
- private static createAsyncProviders;
12
- private static createAsyncOptionsProvider;
13
- private static createSessionManager;
14
21
  }
@@ -1,5 +1,5 @@
1
1
  import { DynamicModule } from '@nestjs/common';
2
- import type { RedisessModuleAsyncOptions, RedisessModuleOptions } from './interfaces/module-options.interface.js';
2
+ import type { RedisessModuleAsyncOptions, RedisessModuleOptions } from './types';
3
3
  export declare class RedisessModule {
4
4
  static forRoot(options: RedisessModuleOptions): DynamicModule;
5
5
  static forRootAsync(options: RedisessModuleAsyncOptions): DynamicModule;
@@ -0,0 +1,21 @@
1
+ import type { Logger } from '@nestjs/common';
2
+ import type { ModuleMetadata } from '@nestjs/common/interfaces';
3
+ import type { InjectionToken } from '@nestjs/common/interfaces/modules/injection-token.interface';
4
+ import type { Cluster, Redis } from 'ioredis';
5
+ import type { SessionManager } from 'redisess';
6
+ export interface RedisessSessionOptions extends SessionManager.Options {
7
+ client: Redis | Cluster;
8
+ }
9
+ export interface RedisessModuleOptions extends BaseModuleOptions {
10
+ useValue: RedisessSessionOptions;
11
+ }
12
+ export interface RedisessModuleAsyncOptions extends BaseModuleOptions, Pick<ModuleMetadata, 'imports'> {
13
+ useFactory?: (...args: any[]) => Promise<RedisessSessionOptions> | RedisessSessionOptions;
14
+ inject?: any[];
15
+ }
16
+ interface BaseModuleOptions {
17
+ token?: InjectionToken;
18
+ logger?: Logger | string;
19
+ global?: boolean;
20
+ }
21
+ export {};
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InjectSessionManager = void 0;
4
- const common_1 = require("@nestjs/common");
5
- const get_session_manager_token_util_js_1 = require("../utils/get-session-manager-token.util.js");
6
- const InjectSessionManager = (name) => (0, common_1.Inject)((0, get_session_manager_token_util_js_1.getSessionManagerToken)(name));
7
- exports.InjectSessionManager = InjectSessionManager;
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getSessionManagerToken = getSessionManagerToken;
4
- const redisess_1 = require("redisess");
5
- function getSessionManagerToken(name) {
6
- if (!name)
7
- return redisess_1.SessionManager;
8
- // noinspection SuspiciousTypeOfGuard
9
- if (typeof name === 'symbol' || typeof name === 'function')
10
- return name;
11
- return `${name}_SessionManager`;
12
- }
@@ -1,3 +0,0 @@
1
- import { Inject } from '@nestjs/common';
2
- import { getSessionManagerToken } from '../utils/get-session-manager-token.util.js';
3
- export const InjectSessionManager = (name) => Inject(getSessionManagerToken(name));
@@ -1,9 +0,0 @@
1
- import { SessionManager } from 'redisess';
2
- export function getSessionManagerToken(name) {
3
- if (!name)
4
- return SessionManager;
5
- // noinspection SuspiciousTypeOfGuard
6
- if (typeof name === 'symbol' || typeof name === 'function')
7
- return name;
8
- return `${name}_SessionManager`;
9
- }
@@ -1 +0,0 @@
1
- export declare const InjectSessionManager: (name?: string) => ParameterDecorator;
@@ -1,21 +0,0 @@
1
- import type { Type } from '@nestjs/common';
2
- import type { ModuleMetadata } from '@nestjs/common/interfaces';
3
- import Redis, { Cluster } from 'ioredis';
4
- import type { SessionManager } from 'redisess';
5
- export interface RedisessModuleOptions extends SessionManager.Options {
6
- /**
7
- * Connection name
8
- */
9
- name?: string;
10
- client: Redis | Cluster;
11
- }
12
- export interface RedisessModuleOptionsFactory {
13
- createOptions(connectionName?: string): Promise<RedisessModuleOptions> | RedisessModuleOptions;
14
- }
15
- export interface RedisessModuleAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
16
- name?: string;
17
- useExisting?: Type<RedisessModuleOptionsFactory>;
18
- useClass?: Type<RedisessModuleOptionsFactory>;
19
- useFactory?: (...args: any[]) => Promise<RedisessModuleOptions> | RedisessModuleOptions;
20
- inject?: any[];
21
- }
@@ -1,3 +0,0 @@
1
- import { Type } from '@nestjs/common';
2
- import { SessionManager } from 'redisess';
3
- export declare function getSessionManagerToken(name?: string | symbol | Type<SessionManager>): string | symbol | Type<SessionManager>;