Skip to content

Commit

Permalink
feat/nestjs-9-support
Browse files Browse the repository at this point in the history
  • Loading branch information
Waqas Jamil committed Jun 7, 2023
1 parent 939f33a commit 6209606
Show file tree
Hide file tree
Showing 8 changed files with 1,683 additions and 2,152 deletions.
6 changes: 5 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
Expand Down
10 changes: 6 additions & 4 deletions dist/redis-client.provider.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ class RedisClientError extends Error {
exports.RedisClientError = RedisClientError;
async function getClient(options) {
const { onClientReady, url, ...opt } = options;
const client = url ? new Redis(url) : new Redis(opt);
const client = url ? new Redis.Redis(url) : new Redis.Redis(opt);
if (onClientReady) {
onClientReady(client);
}
return client;
}
exports.createClient = () => ({
const createClient = () => ({
provide: redis_constants_1.REDIS_CLIENT,
useFactory: async (options) => {
const clients = new Map();
let defaultKey = uuid_1.v4();
let defaultKey = (0, uuid_1.v4)();
if (Array.isArray(options)) {
await Promise.all(options.map(async (o) => {
const key = o.name || defaultKey;
Expand All @@ -43,8 +43,10 @@ exports.createClient = () => ({
},
inject: [redis_constants_1.REDIS_MODULE_OPTIONS],
});
exports.createAsyncClientOptions = (options) => ({
exports.createClient = createClient;
const createAsyncClientOptions = (options) => ({
provide: redis_constants_1.REDIS_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject,
});
exports.createAsyncClientOptions = createAsyncClientOptions;
17 changes: 8 additions & 9 deletions dist/redis-core.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const common_1 = require("@nestjs/common");
const redis_client_provider_1 = require("./redis-client.provider");
const redis_constants_1 = require("./redis.constants");
const redis_service_1 = require("./redis.service");
let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
let RedisCoreModule = exports.RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
constructor(options, redisClient) {
this.options = options;
this.redisClient = redisClient;
Expand All @@ -27,7 +27,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
return {
module: RedisCoreModule_1,
providers: [
redis_client_provider_1.createClient(),
(0, redis_client_provider_1.createClient)(),
{ provide: redis_constants_1.REDIS_MODULE_OPTIONS, useValue: options },
],
exports: [redis_service_1.RedisService],
Expand All @@ -37,7 +37,7 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
return {
module: RedisCoreModule_1,
imports: options.imports,
providers: [redis_client_provider_1.createClient(), redis_client_provider_1.createAsyncClientOptions(options)],
providers: [(0, redis_client_provider_1.createClient)(), (0, redis_client_provider_1.createAsyncClientOptions)(options)],
exports: [redis_service_1.RedisService],
};
}
Expand All @@ -58,14 +58,13 @@ let RedisCoreModule = RedisCoreModule_1 = class RedisCoreModule {
}
}
};
RedisCoreModule = RedisCoreModule_1 = __decorate([
common_1.Global(),
common_1.Module({
exports.RedisCoreModule = RedisCoreModule = RedisCoreModule_1 = __decorate([
(0, common_1.Global)(),
(0, common_1.Module)({
providers: [redis_service_1.RedisService],
exports: [redis_service_1.RedisService],
}),
__param(0, common_1.Inject(redis_constants_1.REDIS_MODULE_OPTIONS)),
__param(1, common_1.Inject(redis_constants_1.REDIS_CLIENT)),
__param(0, (0, common_1.Inject)(redis_constants_1.REDIS_MODULE_OPTIONS)),
__param(1, (0, common_1.Inject)(redis_constants_1.REDIS_CLIENT)),
__metadata("design:paramtypes", [Object, Object])
], RedisCoreModule);
exports.RedisCoreModule = RedisCoreModule;
7 changes: 3 additions & 4 deletions dist/redis.module.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisModule = void 0;
const common_1 = require("@nestjs/common");
const redis_core_module_1 = require("./redis-core.module");
let RedisModule = RedisModule_1 = class RedisModule {
let RedisModule = exports.RedisModule = RedisModule_1 = class RedisModule {
static register(options) {
return {
module: RedisModule_1,
Expand All @@ -24,7 +24,6 @@ let RedisModule = RedisModule_1 = class RedisModule {
};
}
};
RedisModule = RedisModule_1 = __decorate([
common_1.Module({})
exports.RedisModule = RedisModule = RedisModule_1 = __decorate([
(0, common_1.Module)({})
], RedisModule);
exports.RedisModule = RedisModule;
9 changes: 4 additions & 5 deletions dist/redis.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ exports.RedisService = void 0;
const common_1 = require("@nestjs/common");
const redis_constants_1 = require("./redis.constants");
const redis_client_provider_1 = require("./redis-client.provider");
let RedisService = class RedisService {
let RedisService = exports.RedisService = class RedisService {
constructor(redisClient) {
this.redisClient = redisClient;
}
Expand All @@ -33,9 +33,8 @@ let RedisService = class RedisService {
return this.redisClient.clients;
}
};
RedisService = __decorate([
common_1.Injectable(),
__param(0, common_1.Inject(redis_constants_1.REDIS_CLIENT)),
exports.RedisService = RedisService = __decorate([
(0, common_1.Injectable)(),
__param(0, (0, common_1.Inject)(redis_constants_1.REDIS_CLIENT)),
__metadata("design:paramtypes", [Object])
], RedisService);
exports.RedisService = RedisService;
2 changes: 1 addition & 1 deletion lib/redis-client.provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface RedisClient {

async function getClient(options: RedisModuleOptions): Promise<Redis.Redis> {
const { onClientReady, url, ...opt } = options;
const client = url ? new Redis(url) : new Redis(opt);
const client = url ? new Redis.Redis(url) : new Redis.Redis(opt);
if (onClientReady) {
onClientReady(client)
}
Expand Down
39 changes: 19 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,29 @@
"lint": "eslint -c .eslintrc.js"
},
"dependencies": {
"@nestjs/common": "^7.4.4",
"@nestjs/core": "^7.4.4",
"@types/ioredis": "*",
"@types/uuid": "*",
"ioredis": "^4",
"@nestjs/common": "^9.4.2",
"@nestjs/core": "^9.4.2",
"@types/uuid": "9.0.1",
"ioredis": "^5.3.2",
"reflect-metadata": "*",
"rxjs": "^6",
"uuid": "^8"
"rxjs": "^7.8.1",
"uuid": "^9.0.0"
},
"devDependencies": {
"@nestjs/testing": "^7",
"@types/node": "*",
"@typescript-eslint/eslint-plugin": "^4",
"@typescript-eslint/parser": "^4",
"@nestjs/testing": "^9.4.2",
"@types/node": "20.2.5",
"@typescript-eslint/eslint-plugin": "^5.59.9",
"@typescript-eslint/parser": "^5.59.9",
"cz-conventional-changelog": "^3",
"eslint": "*",
"eslint-config-prettier": "^6",
"eslint-plugin-jest": "^24",
"eslint-plugin-prettier": "^3",
"jest": "^26",
"prettier": "^2",
"rimraf": "*",
"ts-jest": "^26",
"typescript": "^4"
"eslint": "8.42.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-jest": "^27.2.1",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^29.5.0",
"prettier": "^2.8.8",
"rimraf": "5.0.1",
"ts-jest": "^29.1.0",
"typescript": "^5.1.3"
},
"keywords": [
"nestjs",
Expand Down
Loading

0 comments on commit 6209606

Please sign in to comment.