@xnestjs/ioredis 1.5.3 → 1.6.0
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 +4 -0
- package/cjs/{get-connection-options.js → get-redis-config.js} +2 -2
- package/cjs/index.js +1 -1
- package/cjs/redis-core.module.js +3 -3
- package/esm/{get-connection-options.js → get-redis-config.js} +1 -1
- package/esm/index.js +1 -1
- package/esm/redis-core.module.js +3 -3
- package/package.json +3 -3
- package/types/get-redis-config.d.ts +2 -0
- package/types/index.d.cts +1 -1
- package/types/index.d.ts +1 -1
- package/types/get-connection-options.d.ts +0 -2
package/README.md
CHANGED
|
@@ -108,6 +108,8 @@ export class MyModule {
|
|
|
108
108
|
The library supports configuration through environment variables. Environment variables below is accepted.
|
|
109
109
|
All environment variables starts with prefix (REDIS_). This can be configured while registering the module.
|
|
110
110
|
|
|
111
|
+
<--- BEGIN env --->
|
|
112
|
+
|
|
111
113
|
### Standalone Connection Variables
|
|
112
114
|
|
|
113
115
|
The following environment variables apply to the standalone connection.
|
|
@@ -140,3 +142,5 @@ The following environment variables apply to the standalone connection.
|
|
|
140
142
|
| REDIS_KEEP_ALIVE | Boolean | | Enable/disable keep-alive functionality. |
|
|
141
143
|
| REDIS_NO_DELAY | Boolean | | Enable/disable the use of Nagle's algorithm. |
|
|
142
144
|
| REDIS_MAX_RETRIES_PER_REQUEST | Number | | Defines max retries per request value |
|
|
145
|
+
|
|
146
|
+
<--- END env --->
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.getRedisConfig = getRedisConfig;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const node_process_1 = tslib_1.__importDefault(require("node:process"));
|
|
6
6
|
const objects_1 = require("@jsopen/objects");
|
|
7
7
|
const putil_varhelpers_1 = require("putil-varhelpers");
|
|
8
8
|
const utils_js_1 = require("./utils.js");
|
|
9
|
-
function
|
|
9
|
+
function getRedisConfig(options, prefix = 'REDIS_') {
|
|
10
10
|
const env = node_process_1.default.env;
|
|
11
11
|
const out = (0, objects_1.clone)(options || {});
|
|
12
12
|
let redisOptions;
|
package/cjs/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./get-
|
|
4
|
+
tslib_1.__exportStar(require("./get-redis-config.js"), exports);
|
|
5
5
|
tslib_1.__exportStar(require("./redis.module.js"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./redis-client.js"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./shared-lock.js"), exports);
|
package/cjs/redis-core.module.js
CHANGED
|
@@ -9,13 +9,13 @@ const ansi_colors_1 = tslib_1.__importDefault(require("ansi-colors"));
|
|
|
9
9
|
const crypto = tslib_1.__importStar(require("crypto"));
|
|
10
10
|
const ioredis_1 = tslib_1.__importStar(require("ioredis"));
|
|
11
11
|
const constants_js_1 = require("./constants.js");
|
|
12
|
-
const
|
|
12
|
+
const get_redis_config_js_1 = require("./get-redis-config.js");
|
|
13
13
|
const redis_client_js_1 = require("./redis-client.js");
|
|
14
14
|
const utils_js_1 = require("./utils.js");
|
|
15
15
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
16
16
|
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
17
17
|
static forRoot(moduleOptions) {
|
|
18
|
-
const connectionOptions = (0,
|
|
18
|
+
const connectionOptions = (0, get_redis_config_js_1.getRedisConfig)(moduleOptions.useValue, moduleOptions.envPrefix);
|
|
19
19
|
return this._createDynamicModule(moduleOptions, {
|
|
20
20
|
global: moduleOptions.global,
|
|
21
21
|
providers: [
|
|
@@ -36,7 +36,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
|
36
36
|
inject: asyncOptions.inject,
|
|
37
37
|
useFactory: async (...args) => {
|
|
38
38
|
const opts = await asyncOptions.useFactory(...args);
|
|
39
|
-
return (0,
|
|
39
|
+
return (0, get_redis_config_js_1.getRedisConfig)(opts, asyncOptions.envPrefix);
|
|
40
40
|
},
|
|
41
41
|
},
|
|
42
42
|
],
|
|
@@ -2,7 +2,7 @@ import process from 'node:process';
|
|
|
2
2
|
import { clone } from '@jsopen/objects';
|
|
3
3
|
import { toBoolean, toInt, toIntDef } from 'putil-varhelpers';
|
|
4
4
|
import { isClusterOptions } from './utils.js';
|
|
5
|
-
export function
|
|
5
|
+
export function getRedisConfig(options, prefix = 'REDIS_') {
|
|
6
6
|
const env = process.env;
|
|
7
7
|
const out = clone(options || {});
|
|
8
8
|
let redisOptions;
|
package/esm/index.js
CHANGED
package/esm/redis-core.module.js
CHANGED
|
@@ -6,13 +6,13 @@ import colors from 'ansi-colors';
|
|
|
6
6
|
import * as crypto from 'crypto';
|
|
7
7
|
import Redis, { Cluster } from 'ioredis';
|
|
8
8
|
import { IOREDIS_CONNECTION_OPTIONS, IOREDIS_MODULE_TOKEN } from './constants.js';
|
|
9
|
-
import {
|
|
9
|
+
import { getRedisConfig } from './get-redis-config.js';
|
|
10
10
|
import { RedisClient } from './redis-client.js';
|
|
11
11
|
import { isClusterOptions, isStandaloneOptions } from './utils.js';
|
|
12
12
|
const CLIENT_TOKEN = Symbol('CLIENT_TOKEN');
|
|
13
13
|
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
14
14
|
static forRoot(moduleOptions) {
|
|
15
|
-
const connectionOptions =
|
|
15
|
+
const connectionOptions = getRedisConfig(moduleOptions.useValue, moduleOptions.envPrefix);
|
|
16
16
|
return this._createDynamicModule(moduleOptions, {
|
|
17
17
|
global: moduleOptions.global,
|
|
18
18
|
providers: [
|
|
@@ -33,7 +33,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
|
33
33
|
inject: asyncOptions.inject,
|
|
34
34
|
useFactory: async (...args) => {
|
|
35
35
|
const opts = await asyncOptions.useFactory(...args);
|
|
36
|
-
return
|
|
36
|
+
return getRedisConfig(opts, asyncOptions.envPrefix);
|
|
37
37
|
},
|
|
38
38
|
},
|
|
39
39
|
],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/ioredis",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "NestJS extension library for ioredis",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,8 +13,8 @@
|
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"@nestjs/common": "^10.0.0 || ^11.0.0",
|
|
15
15
|
"@nestjs/core": "^10.0.0 || ^11.0.0",
|
|
16
|
-
"ioredis": "^5.
|
|
17
|
-
"redis-semaphore": "^5.
|
|
16
|
+
"ioredis": "^5.5.0",
|
|
17
|
+
"redis-semaphore": "^5.6.1"
|
|
18
18
|
},
|
|
19
19
|
"type": "module",
|
|
20
20
|
"exports": {
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import type { RedisClusterConnectionOptions, RedisStandaloneConnectionOptions } from './types';
|
|
2
|
+
export declare function getRedisConfig(options?: RedisStandaloneConnectionOptions | RedisClusterConnectionOptions, prefix?: string): RedisStandaloneConnectionOptions | RedisClusterConnectionOptions;
|
package/types/index.d.cts
CHANGED
package/types/index.d.ts
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import type { RedisClusterConnectionOptions, RedisStandaloneConnectionOptions } from './types';
|
|
2
|
-
export declare function getConnectionOptions(options?: RedisStandaloneConnectionOptions | RedisClusterConnectionOptions, prefix?: string): RedisStandaloneConnectionOptions | RedisClusterConnectionOptions;
|