@xnestjs/ioredis 0.10.4 → 1.0.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/package.json +27 -6
- package/LICENSE +0 -21
- package/cjs/index.js +0 -6
- package/cjs/package.json +0 -3
- package/cjs/redis-client.js +0 -24
- package/cjs/redis-core.module.js +0 -125
- package/cjs/redis.constants.js +0 -5
- package/cjs/redis.interface.js +0 -2
- package/cjs/redis.module.js +0 -25
- package/cjs/utils.js +0 -6
- package/esm/index.js +0 -3
- package/esm/package.json +0 -3
- package/esm/redis-client.js +0 -19
- package/esm/redis-core.module.js +0 -122
- package/esm/redis.constants.js +0 -2
- package/esm/redis.interface.js +0 -1
- package/esm/redis.module.js +0 -22
- package/esm/utils.js +0 -3
- package/types/index.d.cts +0 -3
- package/types/index.d.ts +0 -3
- package/types/redis-client.d.ts +0 -19
- package/types/redis-core.module.d.ts +0 -12
- package/types/redis.constants.d.ts +0 -2
- package/types/redis.interface.d.ts +0 -38
- package/types/redis.module.d.ts +0 -6
- package/types/utils.d.ts +0 -2
package/package.json
CHANGED
|
@@ -1,14 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xnestjs/ioredis",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "NestJS extension library for ioredis",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"compile": "tsc --noEmit",
|
|
9
|
+
"prebuild": "npm run lint && npm run clean",
|
|
10
|
+
"build": "npm run build:cjs && npm run build:esm",
|
|
11
|
+
"build:cjs": "tsc -b tsconfig-build-cjs.json && cp ../../support/package.cjs.json ./build/cjs/package.json",
|
|
12
|
+
"build:esm": "tsc -b tsconfig-build-esm.json && cp ../../support/package.esm.json ./build/esm/package.json",
|
|
13
|
+
"postbuild": "cp README.md ../../LICENSE ./build && node ../../support/postbuild.cjs",
|
|
14
|
+
"lint": "eslint . --max-warnings=0",
|
|
15
|
+
"lint:fix": "eslint . --max-warnings=0 --fix",
|
|
16
|
+
"format": "prettier . --write --log-level=warn",
|
|
17
|
+
"check": "madge --circular src/**",
|
|
18
|
+
"test": "jest",
|
|
19
|
+
"cover": "jest --collect-coverage",
|
|
20
|
+
"clean": "npm run clean:src && npm run clean:build && npm run clean:cover",
|
|
21
|
+
"clean:src": "ts-cleanup -s src --all && ts-cleanup -s test --all",
|
|
22
|
+
"clean:build": "rimraf build",
|
|
23
|
+
"clean:cover": "rimraf coverage"
|
|
24
|
+
},
|
|
7
25
|
"peerDependencies": {
|
|
8
|
-
"@nestjs/common": "^10.4.
|
|
9
|
-
"@nestjs/core": "^10.4.
|
|
10
|
-
"ioredis": "^5.4.
|
|
11
|
-
"
|
|
26
|
+
"@nestjs/common": "^10.4.15",
|
|
27
|
+
"@nestjs/core": "^10.4.15",
|
|
28
|
+
"ioredis": "^5.4.2",
|
|
29
|
+
"redis-semaphore": "^5.6.1"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@nestjs/testing": "^10.4.15"
|
|
12
33
|
},
|
|
13
34
|
"type": "module",
|
|
14
35
|
"exports": {
|
|
@@ -48,4 +69,4 @@
|
|
|
48
69
|
"ioredis",
|
|
49
70
|
"redis"
|
|
50
71
|
]
|
|
51
|
-
}
|
|
72
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2022 Panates
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
package/cjs/index.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./redis.interface.js"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./redis.module.js"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./redis-client.js"), exports);
|
package/cjs/package.json
DELETED
package/cjs/redis-client.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RedisClient = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const redlock_1 = tslib_1.__importDefault(require("redlock"));
|
|
6
|
-
class RedisClient {
|
|
7
|
-
constructor(options) {
|
|
8
|
-
this.cluster = options.cluster;
|
|
9
|
-
this.standalone = options.standalone;
|
|
10
|
-
if (!(this.cluster || this.standalone))
|
|
11
|
-
throw new TypeError('One of "cluster" or "standalone" must be set');
|
|
12
|
-
this._redlock = new redlock_1.default([this.redis], options.lock);
|
|
13
|
-
}
|
|
14
|
-
get isCluster() {
|
|
15
|
-
return !!this.cluster;
|
|
16
|
-
}
|
|
17
|
-
get redis() {
|
|
18
|
-
return (this.cluster || this.standalone);
|
|
19
|
-
}
|
|
20
|
-
get lock() {
|
|
21
|
-
return this._redlock;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.RedisClient = RedisClient;
|
package/cjs/redis-core.module.js
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var RedisCoreModule_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.RedisCoreModule = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const core_1 = require("@nestjs/core");
|
|
8
|
-
const crypto = tslib_1.__importStar(require("crypto"));
|
|
9
|
-
const ioredis_1 = tslib_1.__importStar(require("ioredis"));
|
|
10
|
-
const redis_constants_js_1 = require("./redis.constants.js");
|
|
11
|
-
const redis_client_js_1 = require("./redis-client.js");
|
|
12
|
-
const utils_js_1 = require("./utils.js");
|
|
13
|
-
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
14
|
-
constructor(options, moduleRef) {
|
|
15
|
-
this.options = options;
|
|
16
|
-
this.moduleRef = moduleRef;
|
|
17
|
-
}
|
|
18
|
-
static forRoot(options) {
|
|
19
|
-
const optionsProvider = {
|
|
20
|
-
provide: redis_constants_js_1.IOREDIS_MODULE_OPTIONS,
|
|
21
|
-
useValue: options,
|
|
22
|
-
};
|
|
23
|
-
const token = options.token || redis_client_js_1.RedisClient;
|
|
24
|
-
const connectionProvider = {
|
|
25
|
-
provide: token,
|
|
26
|
-
useFactory: () => this._createClient(options),
|
|
27
|
-
};
|
|
28
|
-
return {
|
|
29
|
-
module: RedisCoreModule_1,
|
|
30
|
-
providers: [connectionProvider, optionsProvider],
|
|
31
|
-
exports: [connectionProvider],
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
static forRootAsync(asyncOptions) {
|
|
35
|
-
if (!asyncOptions.useFactory)
|
|
36
|
-
throw new Error('Invalid configuration. Must provide "useFactory"');
|
|
37
|
-
const token = asyncOptions.token || redis_client_js_1.RedisClient;
|
|
38
|
-
const connectionProvider = {
|
|
39
|
-
provide: token,
|
|
40
|
-
inject: [redis_constants_js_1.IOREDIS_MODULE_OPTIONS],
|
|
41
|
-
useFactory: async (moduleOptions) => this._createClient(moduleOptions),
|
|
42
|
-
};
|
|
43
|
-
return {
|
|
44
|
-
module: RedisCoreModule_1,
|
|
45
|
-
imports: asyncOptions.imports,
|
|
46
|
-
providers: [
|
|
47
|
-
{
|
|
48
|
-
provide: redis_constants_js_1.IOREDIS_MODULE_OPTIONS,
|
|
49
|
-
useFactory: asyncOptions.useFactory,
|
|
50
|
-
inject: asyncOptions.inject || [],
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
provide: redis_constants_js_1.IOREDIS_MODULE_TOKEN,
|
|
54
|
-
useValue: crypto.randomUUID(),
|
|
55
|
-
},
|
|
56
|
-
connectionProvider,
|
|
57
|
-
],
|
|
58
|
-
exports: [connectionProvider],
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
static async _createClient(options) {
|
|
62
|
-
if (options.host && options.nodes) {
|
|
63
|
-
throw new TypeError(`You should set either "host" or "nodes", not both`);
|
|
64
|
-
}
|
|
65
|
-
const opts = { ...options };
|
|
66
|
-
const isCluster = (0, utils_js_1.isClusterOptions)(opts);
|
|
67
|
-
let client;
|
|
68
|
-
if (isCluster) {
|
|
69
|
-
delete opts.name;
|
|
70
|
-
delete opts.nodes;
|
|
71
|
-
const cluster = new ioredis_1.Cluster(opts.nodes, opts);
|
|
72
|
-
client = new redis_client_js_1.RedisClient({ cluster, lock: options.lock });
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
if (options.host && options.host.includes('://')) {
|
|
76
|
-
const url = new URL(options.host);
|
|
77
|
-
options.host = url.hostname;
|
|
78
|
-
if (url.port)
|
|
79
|
-
options.port = parseInt(url.port, 10);
|
|
80
|
-
if (url.username)
|
|
81
|
-
options.username = url.username;
|
|
82
|
-
if (url.password)
|
|
83
|
-
options.password = url.password;
|
|
84
|
-
if (url.protocol === 'rediss:') {
|
|
85
|
-
// @ts-ignore
|
|
86
|
-
options.tls = true;
|
|
87
|
-
}
|
|
88
|
-
const db = parseInt(url.pathname.substring(1), 10);
|
|
89
|
-
if (db > 0)
|
|
90
|
-
options.db = db;
|
|
91
|
-
}
|
|
92
|
-
const standalone = new ioredis_1.default(options);
|
|
93
|
-
client = new redis_client_js_1.RedisClient({ standalone, lock: options.lock });
|
|
94
|
-
}
|
|
95
|
-
if (!options.lazyConnect) {
|
|
96
|
-
await new Promise((resolve, reject) => {
|
|
97
|
-
client.redis.once('ready', () => {
|
|
98
|
-
client.redis.removeListener('error', reject);
|
|
99
|
-
resolve();
|
|
100
|
-
});
|
|
101
|
-
client.redis.once('error', e => {
|
|
102
|
-
client.redis.removeListener('ready', resolve);
|
|
103
|
-
reject(e);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
return client;
|
|
108
|
-
}
|
|
109
|
-
async onApplicationShutdown() {
|
|
110
|
-
try {
|
|
111
|
-
const client = this.moduleRef.get(this.options.token || redis_client_js_1.RedisClient);
|
|
112
|
-
await client.redis.quit();
|
|
113
|
-
}
|
|
114
|
-
catch {
|
|
115
|
-
//
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
};
|
|
119
|
-
exports.RedisCoreModule = RedisCoreModule;
|
|
120
|
-
exports.RedisCoreModule = RedisCoreModule = RedisCoreModule_1 = tslib_1.__decorate([
|
|
121
|
-
(0, common_1.Global)(),
|
|
122
|
-
(0, common_1.Module)({}),
|
|
123
|
-
tslib_1.__param(0, (0, common_1.Inject)(redis_constants_js_1.IOREDIS_MODULE_OPTIONS)),
|
|
124
|
-
tslib_1.__metadata("design:paramtypes", [Object, core_1.ModuleRef])
|
|
125
|
-
], RedisCoreModule);
|
package/cjs/redis.constants.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IOREDIS_MODULE_TOKEN = exports.IOREDIS_MODULE_OPTIONS = void 0;
|
|
4
|
-
exports.IOREDIS_MODULE_OPTIONS = Symbol('IOREDIS_MODULE_OPTIONS');
|
|
5
|
-
exports.IOREDIS_MODULE_TOKEN = Symbol('IOREDIS_MODULE_ID');
|
package/cjs/redis.interface.js
DELETED
package/cjs/redis.module.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var RedisModule_1;
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.RedisModule = void 0;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const common_1 = require("@nestjs/common");
|
|
7
|
-
const redis_core_module_js_1 = require("./redis-core.module.js");
|
|
8
|
-
let RedisModule = RedisModule_1 = class RedisModule {
|
|
9
|
-
static forRoot(options) {
|
|
10
|
-
return {
|
|
11
|
-
module: RedisModule_1,
|
|
12
|
-
imports: [redis_core_module_js_1.RedisCoreModule.forRoot(options)],
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
static forRootAsync(options) {
|
|
16
|
-
return {
|
|
17
|
-
module: RedisModule_1,
|
|
18
|
-
imports: [redis_core_module_js_1.RedisCoreModule.forRootAsync(options)],
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
exports.RedisModule = RedisModule;
|
|
23
|
-
exports.RedisModule = RedisModule = RedisModule_1 = tslib_1.__decorate([
|
|
24
|
-
(0, common_1.Module)({})
|
|
25
|
-
], RedisModule);
|
package/cjs/utils.js
DELETED
package/esm/index.js
DELETED
package/esm/package.json
DELETED
package/esm/redis-client.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import Redlock from 'redlock';
|
|
2
|
-
export class RedisClient {
|
|
3
|
-
constructor(options) {
|
|
4
|
-
this.cluster = options.cluster;
|
|
5
|
-
this.standalone = options.standalone;
|
|
6
|
-
if (!(this.cluster || this.standalone))
|
|
7
|
-
throw new TypeError('One of "cluster" or "standalone" must be set');
|
|
8
|
-
this._redlock = new Redlock([this.redis], options.lock);
|
|
9
|
-
}
|
|
10
|
-
get isCluster() {
|
|
11
|
-
return !!this.cluster;
|
|
12
|
-
}
|
|
13
|
-
get redis() {
|
|
14
|
-
return (this.cluster || this.standalone);
|
|
15
|
-
}
|
|
16
|
-
get lock() {
|
|
17
|
-
return this._redlock;
|
|
18
|
-
}
|
|
19
|
-
}
|
package/esm/redis-core.module.js
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
var RedisCoreModule_1;
|
|
2
|
-
import { __decorate, __metadata, __param } from "tslib";
|
|
3
|
-
import { Global, Inject, Module } from '@nestjs/common';
|
|
4
|
-
import { ModuleRef } from '@nestjs/core';
|
|
5
|
-
import * as crypto from 'crypto';
|
|
6
|
-
import Redis, { Cluster } from 'ioredis';
|
|
7
|
-
import { IOREDIS_MODULE_OPTIONS, IOREDIS_MODULE_TOKEN } from './redis.constants.js';
|
|
8
|
-
import { RedisClient } from './redis-client.js';
|
|
9
|
-
import { isClusterOptions } from './utils.js';
|
|
10
|
-
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
|
|
11
|
-
constructor(options, moduleRef) {
|
|
12
|
-
this.options = options;
|
|
13
|
-
this.moduleRef = moduleRef;
|
|
14
|
-
}
|
|
15
|
-
static forRoot(options) {
|
|
16
|
-
const optionsProvider = {
|
|
17
|
-
provide: IOREDIS_MODULE_OPTIONS,
|
|
18
|
-
useValue: options,
|
|
19
|
-
};
|
|
20
|
-
const token = options.token || RedisClient;
|
|
21
|
-
const connectionProvider = {
|
|
22
|
-
provide: token,
|
|
23
|
-
useFactory: () => this._createClient(options),
|
|
24
|
-
};
|
|
25
|
-
return {
|
|
26
|
-
module: RedisCoreModule_1,
|
|
27
|
-
providers: [connectionProvider, optionsProvider],
|
|
28
|
-
exports: [connectionProvider],
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
static forRootAsync(asyncOptions) {
|
|
32
|
-
if (!asyncOptions.useFactory)
|
|
33
|
-
throw new Error('Invalid configuration. Must provide "useFactory"');
|
|
34
|
-
const token = asyncOptions.token || RedisClient;
|
|
35
|
-
const connectionProvider = {
|
|
36
|
-
provide: token,
|
|
37
|
-
inject: [IOREDIS_MODULE_OPTIONS],
|
|
38
|
-
useFactory: async (moduleOptions) => this._createClient(moduleOptions),
|
|
39
|
-
};
|
|
40
|
-
return {
|
|
41
|
-
module: RedisCoreModule_1,
|
|
42
|
-
imports: asyncOptions.imports,
|
|
43
|
-
providers: [
|
|
44
|
-
{
|
|
45
|
-
provide: IOREDIS_MODULE_OPTIONS,
|
|
46
|
-
useFactory: asyncOptions.useFactory,
|
|
47
|
-
inject: asyncOptions.inject || [],
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
provide: IOREDIS_MODULE_TOKEN,
|
|
51
|
-
useValue: crypto.randomUUID(),
|
|
52
|
-
},
|
|
53
|
-
connectionProvider,
|
|
54
|
-
],
|
|
55
|
-
exports: [connectionProvider],
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
static async _createClient(options) {
|
|
59
|
-
if (options.host && options.nodes) {
|
|
60
|
-
throw new TypeError(`You should set either "host" or "nodes", not both`);
|
|
61
|
-
}
|
|
62
|
-
const opts = { ...options };
|
|
63
|
-
const isCluster = isClusterOptions(opts);
|
|
64
|
-
let client;
|
|
65
|
-
if (isCluster) {
|
|
66
|
-
delete opts.name;
|
|
67
|
-
delete opts.nodes;
|
|
68
|
-
const cluster = new Cluster(opts.nodes, opts);
|
|
69
|
-
client = new RedisClient({ cluster, lock: options.lock });
|
|
70
|
-
}
|
|
71
|
-
else {
|
|
72
|
-
if (options.host && options.host.includes('://')) {
|
|
73
|
-
const url = new URL(options.host);
|
|
74
|
-
options.host = url.hostname;
|
|
75
|
-
if (url.port)
|
|
76
|
-
options.port = parseInt(url.port, 10);
|
|
77
|
-
if (url.username)
|
|
78
|
-
options.username = url.username;
|
|
79
|
-
if (url.password)
|
|
80
|
-
options.password = url.password;
|
|
81
|
-
if (url.protocol === 'rediss:') {
|
|
82
|
-
// @ts-ignore
|
|
83
|
-
options.tls = true;
|
|
84
|
-
}
|
|
85
|
-
const db = parseInt(url.pathname.substring(1), 10);
|
|
86
|
-
if (db > 0)
|
|
87
|
-
options.db = db;
|
|
88
|
-
}
|
|
89
|
-
const standalone = new Redis(options);
|
|
90
|
-
client = new RedisClient({ standalone, lock: options.lock });
|
|
91
|
-
}
|
|
92
|
-
if (!options.lazyConnect) {
|
|
93
|
-
await new Promise((resolve, reject) => {
|
|
94
|
-
client.redis.once('ready', () => {
|
|
95
|
-
client.redis.removeListener('error', reject);
|
|
96
|
-
resolve();
|
|
97
|
-
});
|
|
98
|
-
client.redis.once('error', e => {
|
|
99
|
-
client.redis.removeListener('ready', resolve);
|
|
100
|
-
reject(e);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
return client;
|
|
105
|
-
}
|
|
106
|
-
async onApplicationShutdown() {
|
|
107
|
-
try {
|
|
108
|
-
const client = this.moduleRef.get(this.options.token || RedisClient);
|
|
109
|
-
await client.redis.quit();
|
|
110
|
-
}
|
|
111
|
-
catch {
|
|
112
|
-
//
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
};
|
|
116
|
-
RedisCoreModule = RedisCoreModule_1 = __decorate([
|
|
117
|
-
Global(),
|
|
118
|
-
Module({}),
|
|
119
|
-
__param(0, Inject(IOREDIS_MODULE_OPTIONS)),
|
|
120
|
-
__metadata("design:paramtypes", [Object, ModuleRef])
|
|
121
|
-
], RedisCoreModule);
|
|
122
|
-
export { RedisCoreModule };
|
package/esm/redis.constants.js
DELETED
package/esm/redis.interface.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/esm/redis.module.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
var RedisModule_1;
|
|
2
|
-
import { __decorate } from "tslib";
|
|
3
|
-
import { Module } from '@nestjs/common';
|
|
4
|
-
import { RedisCoreModule } from './redis-core.module.js';
|
|
5
|
-
let RedisModule = RedisModule_1 = class RedisModule {
|
|
6
|
-
static forRoot(options) {
|
|
7
|
-
return {
|
|
8
|
-
module: RedisModule_1,
|
|
9
|
-
imports: [RedisCoreModule.forRoot(options)],
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
static forRootAsync(options) {
|
|
13
|
-
return {
|
|
14
|
-
module: RedisModule_1,
|
|
15
|
-
imports: [RedisCoreModule.forRootAsync(options)],
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
RedisModule = RedisModule_1 = __decorate([
|
|
20
|
-
Module({})
|
|
21
|
-
], RedisModule);
|
|
22
|
-
export { RedisModule };
|
package/esm/utils.js
DELETED
package/types/index.d.cts
DELETED
package/types/index.d.ts
DELETED
package/types/redis-client.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Cluster as IORedisCluster, Redis as IORedisClient } from 'ioredis';
|
|
2
|
-
import Redlock from 'redlock';
|
|
3
|
-
import type { LockSettings } from './redis.interface.js';
|
|
4
|
-
export declare namespace RedisClient {
|
|
5
|
-
interface Options {
|
|
6
|
-
cluster?: IORedisCluster;
|
|
7
|
-
standalone?: IORedisClient;
|
|
8
|
-
lock?: LockSettings;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
export declare class RedisClient {
|
|
12
|
-
readonly _redlock: Redlock;
|
|
13
|
-
cluster?: IORedisCluster;
|
|
14
|
-
standalone?: IORedisClient;
|
|
15
|
-
constructor(options: RedisClient.Options);
|
|
16
|
-
get isCluster(): boolean;
|
|
17
|
-
get redis(): IORedisCluster | IORedisClient;
|
|
18
|
-
get lock(): Redlock;
|
|
19
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DynamicModule, OnApplicationShutdown } from '@nestjs/common';
|
|
2
|
-
import { ModuleRef } from '@nestjs/core';
|
|
3
|
-
import { RedisClientAsyncOptions, RedisClientOptions, RedisClusterAsyncOptions, RedisClusterOptions } from './redis.interface.js';
|
|
4
|
-
export declare class RedisCoreModule implements OnApplicationShutdown {
|
|
5
|
-
private readonly options;
|
|
6
|
-
private readonly moduleRef;
|
|
7
|
-
constructor(options: RedisClientOptions | RedisClusterOptions, moduleRef: ModuleRef);
|
|
8
|
-
static forRoot(options: RedisClientOptions | RedisClusterOptions): DynamicModule;
|
|
9
|
-
static forRootAsync(asyncOptions: RedisClientAsyncOptions | RedisClusterAsyncOptions): DynamicModule;
|
|
10
|
-
private static _createClient;
|
|
11
|
-
onApplicationShutdown(): Promise<void>;
|
|
12
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { ModuleMetadata } from '@nestjs/common/interfaces';
|
|
2
|
-
import type { RedisOptions } from 'ioredis';
|
|
3
|
-
import type { ClusterOptions } from 'ioredis/built/cluster/ClusterOptions';
|
|
4
|
-
import type { ClusterNode } from 'ioredis/built/cluster/index.js';
|
|
5
|
-
import type { Lock, Settings as RedlockSettings } from 'redlock';
|
|
6
|
-
export interface RedisClientOptions extends RedisOptions {
|
|
7
|
-
/**
|
|
8
|
-
* Injection token
|
|
9
|
-
*/
|
|
10
|
-
token?: any;
|
|
11
|
-
lock?: LockSettings;
|
|
12
|
-
}
|
|
13
|
-
export interface RedisClusterOptions extends ClusterOptions {
|
|
14
|
-
/**
|
|
15
|
-
* Injection token
|
|
16
|
-
*/
|
|
17
|
-
token?: any;
|
|
18
|
-
nodes: ClusterNode[];
|
|
19
|
-
}
|
|
20
|
-
export interface RedisClientAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
21
|
-
/**
|
|
22
|
-
* Injection token
|
|
23
|
-
*/
|
|
24
|
-
token?: any;
|
|
25
|
-
useFactory?: (...args: any[]) => Promise<RedisClientOptions> | RedisClientOptions;
|
|
26
|
-
inject?: any[];
|
|
27
|
-
}
|
|
28
|
-
export interface RedisClusterAsyncOptions extends Pick<ModuleMetadata, 'imports'> {
|
|
29
|
-
/**
|
|
30
|
-
* Injection token
|
|
31
|
-
*/
|
|
32
|
-
token?: any;
|
|
33
|
-
useFactory?: (...args: any[]) => Promise<RedisClusterOptions> | RedisClusterOptions;
|
|
34
|
-
inject?: any[];
|
|
35
|
-
}
|
|
36
|
-
export interface LockSettings extends RedlockSettings {
|
|
37
|
-
}
|
|
38
|
-
export { Lock };
|
package/types/redis.module.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { DynamicModule } from '@nestjs/common';
|
|
2
|
-
import { RedisClientAsyncOptions, RedisClientOptions, RedisClusterAsyncOptions, RedisClusterOptions } from './redis.interface.js';
|
|
3
|
-
export declare class RedisModule {
|
|
4
|
-
static forRoot(options: RedisClientOptions | RedisClusterOptions): DynamicModule;
|
|
5
|
-
static forRootAsync(options: RedisClientAsyncOptions | RedisClusterAsyncOptions): DynamicModule;
|
|
6
|
-
}
|
package/types/utils.d.ts
DELETED