@nest-boot/redis 7.0.1 → 7.0.2
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/dist/index.d.ts +1 -3
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/redis.module-definition.d.ts +2 -8
- package/dist/redis.module-definition.js +1 -8
- package/dist/redis.module-definition.js.map +1 -1
- package/dist/redis.module.d.ts +65 -3
- package/dist/redis.module.js +75 -5
- package/dist/redis.module.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/load-config-from-env.util.d.ts +14 -0
- package/dist/utils/load-config-from-env.util.js +14 -0
- package/dist/utils/load-config-from-env.util.js.map +1 -1
- package/package.json +5 -5
- package/dist/redis.d.ts +0 -3
- package/dist/redis.js +0 -21
- package/dist/redis.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -14,8 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.Redis = void 0;
|
|
18
|
-
const redis_1 = require("./redis");
|
|
19
|
-
Object.defineProperty(exports, "Redis", { enumerable: true, get: function () { return redis_1.Redis; } });
|
|
20
17
|
__exportStar(require("./redis.module"), exports);
|
|
18
|
+
__exportStar(require("./utils/load-config-from-env.util"), exports);
|
|
21
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,oEAAkD"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type RedisOptions } from "ioredis";
|
|
2
|
-
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RedisOptions, "register", "create", {
|
|
3
|
-
isGlobal: boolean;
|
|
4
|
-
}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: import("ioredis").CommonRedisOptions & import("ioredis").SentinelConnectionOptions & Partial<{
|
|
2
|
+
export declare const ConfigurableModuleClass: import("@nestjs/common").ConfigurableModuleCls<RedisOptions, "register", "create", {}>, MODULE_OPTIONS_TOKEN: string | symbol, OPTIONS_TYPE: import("ioredis").CommonRedisOptions & import("ioredis").SentinelConnectionOptions & Partial<{
|
|
5
3
|
port: number;
|
|
6
4
|
host?: string | undefined | undefined;
|
|
7
5
|
family?: number | undefined | undefined;
|
|
@@ -10,8 +8,4 @@ export declare const ConfigurableModuleClass: import("@nestjs/common").Configura
|
|
|
10
8
|
}> & {
|
|
11
9
|
disconnectTimeout?: number;
|
|
12
10
|
tls?: import("tls").ConnectionOptions;
|
|
13
|
-
} & Partial<{
|
|
14
|
-
isGlobal: boolean;
|
|
15
|
-
}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<RedisOptions, "create"> & Partial<{
|
|
16
|
-
isGlobal: boolean;
|
|
17
|
-
}>;
|
|
11
|
+
} & Partial<{}>, ASYNC_OPTIONS_TYPE: import("@nestjs/common").ConfigurableModuleAsyncOptions<RedisOptions, "create"> & Partial<{}>;
|
|
@@ -3,12 +3,5 @@ var _a;
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.ASYNC_OPTIONS_TYPE = exports.OPTIONS_TYPE = exports.MODULE_OPTIONS_TOKEN = exports.ConfigurableModuleClass = void 0;
|
|
5
5
|
const common_1 = require("@nestjs/common");
|
|
6
|
-
_a = new common_1.ConfigurableModuleBuilder()
|
|
7
|
-
.setExtras({
|
|
8
|
-
isGlobal: false,
|
|
9
|
-
}, (definition, extras) => ({
|
|
10
|
-
...definition,
|
|
11
|
-
global: extras.isGlobal,
|
|
12
|
-
}))
|
|
13
|
-
.build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
|
|
6
|
+
_a = new common_1.ConfigurableModuleBuilder().build(), exports.ConfigurableModuleClass = _a.ConfigurableModuleClass, exports.MODULE_OPTIONS_TOKEN = _a.MODULE_OPTIONS_TOKEN, exports.OPTIONS_TYPE = _a.OPTIONS_TYPE, exports.ASYNC_OPTIONS_TYPE = _a.ASYNC_OPTIONS_TYPE;
|
|
14
7
|
//# sourceMappingURL=redis.module-definition.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.module-definition.js","sourceRoot":"","sources":["../src/redis.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KAKT,IAAI,kCAAyB,EAAgB
|
|
1
|
+
{"version":3,"file":"redis.module-definition.js","sourceRoot":"","sources":["../src/redis.module-definition.ts"],"names":[],"mappings":";;;;AAAA,2CAA2D;AAG9C,KAKT,IAAI,kCAAyB,EAAgB,CAAC,KAAK,EAAE,EAJvD,+BAAuB,+BACvB,4BAAoB,4BACpB,oBAAY,oBACZ,0BAAkB,yBACsC"}
|
package/dist/redis.module.d.ts
CHANGED
|
@@ -1,8 +1,70 @@
|
|
|
1
|
-
import { type OnApplicationShutdown } from "@nestjs/common";
|
|
2
|
-
import
|
|
3
|
-
import { ConfigurableModuleClass } from "./redis.module-definition";
|
|
1
|
+
import { type DynamicModule, type OnApplicationShutdown } from "@nestjs/common";
|
|
2
|
+
import Redis from "ioredis";
|
|
3
|
+
import { ASYNC_OPTIONS_TYPE, ConfigurableModuleClass, OPTIONS_TYPE } from "./redis.module-definition";
|
|
4
|
+
/**
|
|
5
|
+
* Module that provides Redis connection using ioredis.
|
|
6
|
+
*
|
|
7
|
+
* The module automatically loads configuration from environment variables if not provided:
|
|
8
|
+
* - `REDIS_URL`: Full Redis connection URL (e.g., redis://user:pass@host:6379/0)
|
|
9
|
+
* - `REDIS_HOST`: Redis server hostname
|
|
10
|
+
* - `REDIS_PORT`: Redis server port
|
|
11
|
+
* - `REDIS_DB` or `REDIS_DATABASE`: Redis database number
|
|
12
|
+
* - `REDIS_USER` or `REDIS_USERNAME`: Redis username
|
|
13
|
+
* - `REDIS_PASS` or `REDIS_PASSWORD`: Redis password
|
|
14
|
+
* - `REDIS_TLS`: Enable TLS connection
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { RedisModule } from '@nest-boot/redis';
|
|
19
|
+
*
|
|
20
|
+
* @Module({
|
|
21
|
+
* imports: [
|
|
22
|
+
* RedisModule.register({
|
|
23
|
+
* host: 'localhost',
|
|
24
|
+
* port: 6379,
|
|
25
|
+
* isGlobal: true,
|
|
26
|
+
* }),
|
|
27
|
+
* ],
|
|
28
|
+
* })
|
|
29
|
+
* export class AppModule {}
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* // Inject Redis client in your service
|
|
35
|
+
* import { Redis } from 'ioredis';
|
|
36
|
+
*
|
|
37
|
+
* @Injectable()
|
|
38
|
+
* export class CacheService {
|
|
39
|
+
* constructor(private readonly redis: Redis) {}
|
|
40
|
+
*
|
|
41
|
+
* async get(key: string): Promise<string | null> {
|
|
42
|
+
* return this.redis.get(key);
|
|
43
|
+
* }
|
|
44
|
+
* }
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
4
47
|
export declare class RedisModule extends ConfigurableModuleClass implements OnApplicationShutdown {
|
|
5
48
|
private readonly redis;
|
|
49
|
+
/**
|
|
50
|
+
* Registers the RedisModule with the given options.
|
|
51
|
+
* @param options - Redis connection options and isGlobal flag
|
|
52
|
+
* @returns Dynamic module configuration
|
|
53
|
+
*/
|
|
54
|
+
static register(options: typeof OPTIONS_TYPE): DynamicModule;
|
|
55
|
+
/**
|
|
56
|
+
* Registers the RedisModule asynchronously with factory functions.
|
|
57
|
+
* @param options - Async configuration options
|
|
58
|
+
* @returns Dynamic module configuration
|
|
59
|
+
*/
|
|
60
|
+
static registerAsync(options: typeof ASYNC_OPTIONS_TYPE): DynamicModule;
|
|
61
|
+
/**
|
|
62
|
+
* Creates an instance of RedisModule.
|
|
63
|
+
* @param redis - The Redis client instance
|
|
64
|
+
*/
|
|
6
65
|
constructor(redis: Redis);
|
|
66
|
+
/**
|
|
67
|
+
* Gracefully closes the Redis connection when the application shuts down.
|
|
68
|
+
*/
|
|
7
69
|
onApplicationShutdown(): Promise<void>;
|
|
8
70
|
}
|
package/dist/redis.module.js
CHANGED
|
@@ -8,36 +8,106 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.RedisModule = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
14
|
-
const
|
|
17
|
+
const ioredis_1 = __importDefault(require("ioredis"));
|
|
15
18
|
const redis_module_definition_1 = require("./redis.module-definition");
|
|
16
19
|
const load_config_from_env_util_1 = require("./utils/load-config-from-env.util");
|
|
20
|
+
/**
|
|
21
|
+
* Module that provides Redis connection using ioredis.
|
|
22
|
+
*
|
|
23
|
+
* The module automatically loads configuration from environment variables if not provided:
|
|
24
|
+
* - `REDIS_URL`: Full Redis connection URL (e.g., redis://user:pass@host:6379/0)
|
|
25
|
+
* - `REDIS_HOST`: Redis server hostname
|
|
26
|
+
* - `REDIS_PORT`: Redis server port
|
|
27
|
+
* - `REDIS_DB` or `REDIS_DATABASE`: Redis database number
|
|
28
|
+
* - `REDIS_USER` or `REDIS_USERNAME`: Redis username
|
|
29
|
+
* - `REDIS_PASS` or `REDIS_PASSWORD`: Redis password
|
|
30
|
+
* - `REDIS_TLS`: Enable TLS connection
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* import { RedisModule } from '@nest-boot/redis';
|
|
35
|
+
*
|
|
36
|
+
* @Module({
|
|
37
|
+
* imports: [
|
|
38
|
+
* RedisModule.register({
|
|
39
|
+
* host: 'localhost',
|
|
40
|
+
* port: 6379,
|
|
41
|
+
* isGlobal: true,
|
|
42
|
+
* }),
|
|
43
|
+
* ],
|
|
44
|
+
* })
|
|
45
|
+
* export class AppModule {}
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // Inject Redis client in your service
|
|
51
|
+
* import { Redis } from 'ioredis';
|
|
52
|
+
*
|
|
53
|
+
* @Injectable()
|
|
54
|
+
* export class CacheService {
|
|
55
|
+
* constructor(private readonly redis: Redis) {}
|
|
56
|
+
*
|
|
57
|
+
* async get(key: string): Promise<string | null> {
|
|
58
|
+
* return this.redis.get(key);
|
|
59
|
+
* }
|
|
60
|
+
* }
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
17
63
|
let RedisModule = class RedisModule extends redis_module_definition_1.ConfigurableModuleClass {
|
|
64
|
+
/**
|
|
65
|
+
* Registers the RedisModule with the given options.
|
|
66
|
+
* @param options - Redis connection options and isGlobal flag
|
|
67
|
+
* @returns Dynamic module configuration
|
|
68
|
+
*/
|
|
69
|
+
static register(options) {
|
|
70
|
+
return super.register(options);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Registers the RedisModule asynchronously with factory functions.
|
|
74
|
+
* @param options - Async configuration options
|
|
75
|
+
* @returns Dynamic module configuration
|
|
76
|
+
*/
|
|
77
|
+
static registerAsync(options) {
|
|
78
|
+
return super.registerAsync(options);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Creates an instance of RedisModule.
|
|
82
|
+
* @param redis - The Redis client instance
|
|
83
|
+
*/
|
|
18
84
|
constructor(redis) {
|
|
19
85
|
super();
|
|
20
86
|
this.redis = redis;
|
|
21
87
|
}
|
|
88
|
+
/**
|
|
89
|
+
* Gracefully closes the Redis connection when the application shuts down.
|
|
90
|
+
*/
|
|
22
91
|
async onApplicationShutdown() {
|
|
23
92
|
await this.redis.quit();
|
|
24
93
|
}
|
|
25
94
|
};
|
|
26
95
|
exports.RedisModule = RedisModule;
|
|
27
96
|
exports.RedisModule = RedisModule = __decorate([
|
|
97
|
+
(0, common_1.Global)(),
|
|
28
98
|
(0, common_1.Module)({
|
|
29
99
|
providers: [
|
|
30
100
|
{
|
|
31
|
-
provide:
|
|
101
|
+
provide: ioredis_1.default,
|
|
32
102
|
inject: [{ token: redis_module_definition_1.MODULE_OPTIONS_TOKEN, optional: true }],
|
|
33
|
-
useFactory: (options
|
|
103
|
+
useFactory: (options) => new ioredis_1.default({
|
|
34
104
|
...(0, load_config_from_env_util_1.loadConfigFromEnv)(),
|
|
35
105
|
...options,
|
|
36
106
|
}),
|
|
37
107
|
},
|
|
38
108
|
],
|
|
39
|
-
exports: [
|
|
109
|
+
exports: [ioredis_1.default],
|
|
40
110
|
}),
|
|
41
|
-
__metadata("design:paramtypes", [
|
|
111
|
+
__metadata("design:paramtypes", [ioredis_1.default])
|
|
42
112
|
], RedisModule);
|
|
43
113
|
//# sourceMappingURL=redis.module.js.map
|
package/dist/redis.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../src/redis.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"redis.module.js","sourceRoot":"","sources":["../src/redis.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAKwB;AACxB,sDAAmD;AAEnD,uEAKmC;AACnC,iFAAsE;AAEtE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;AAgBI,IAAM,WAAW,GAAjB,MAAM,WACX,SAAQ,iDAAuB;IAG/B;;;;OAIG;IACH,MAAM,CAAU,QAAQ,CAAC,OAA4B;QACnD,OAAO,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IACjC,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAU,aAAa,CAC3B,OAAkC;QAElC,OAAO,KAAK,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;;OAGG;IACH,YAA6B,KAAY;QACvC,KAAK,EAAE,CAAC;QADmB,UAAK,GAAL,KAAK,CAAO;IAEzC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,qBAAqB;QACzB,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;IAC1B,CAAC;CACF,CAAA;AAtCY,kCAAW;sBAAX,WAAW;IAfvB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC;QACN,SAAS,EAAE;YACT;gBACE,OAAO,EAAE,iBAAK;gBACd,MAAM,EAAE,CAAC,EAAE,KAAK,EAAE,8CAAoB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;gBACzD,UAAU,EAAE,CAAC,OAAqB,EAAE,EAAE,CACpC,IAAI,iBAAK,CAAC;oBACR,GAAG,IAAA,6CAAiB,GAAE;oBACtB,GAAG,OAAO;iBACX,CAAC;aACL;SACF;QACD,OAAO,EAAE,CAAC,iBAAK,CAAC;KACjB,CAAC;qCA6BoC,iBAAK;GA5B9B,WAAW,CAsCvB"}
|