@replicode/redis
Advanced tools
Comparing version 1.0.0 to 1.0.1
export interface RedisOptions { | ||
api_key: string; | ||
connection_string: string; | ||
} | ||
export declare const defaultRedisOptions: RedisOptions; | ||
//# sourceMappingURL=redis.options.d.ts.map |
@@ -5,4 +5,4 @@ "use strict"; | ||
exports.defaultRedisOptions = { | ||
api_key: '' | ||
connection_string: '' | ||
}; | ||
//# sourceMappingURL=redis.options.js.map |
import { RedisOptions } from './redis.options'; | ||
import { RedisClientType } from 'redis'; | ||
export declare class RedisService { | ||
private options; | ||
private logger; | ||
client: RedisClientType; | ||
constructor(options: Partial<RedisOptions>); | ||
redisConnect(): Promise<void>; | ||
initialize(): Promise<void>; | ||
} | ||
//# sourceMappingURL=redis.service.d.ts.map |
@@ -15,6 +15,23 @@ "use strict"; | ||
const redis_options_1 = require("./redis.options"); | ||
const redis_1 = require("redis"); | ||
let RedisService = class RedisService { | ||
constructor(options) { | ||
this.logger = new common_1.Logger('RedisService'); | ||
this.options = Object.assign({}, redis_options_1.defaultRedisOptions, options); | ||
this.initialize(); | ||
} | ||
async redisConnect() { | ||
this.client.connect().catch(error => { | ||
this.logger.log(`Redis error on connect: ${error}`); | ||
}); | ||
} | ||
async initialize() { | ||
this.client = (0, redis_1.createClient)({ url: this.options.connection_string }); | ||
this.redisConnect(); | ||
this.client.on('error', async (err) => { | ||
this.logger.log(`Redis error: ${err}`); | ||
await this.client.disconnect(); | ||
this.redisConnect(); | ||
}); | ||
} | ||
}; | ||
@@ -21,0 +38,0 @@ RedisService = __decorate([ |
{ | ||
"name": "@replicode/redis", | ||
"version": "1.0.0", | ||
"version": "1.0.01", | ||
"description": "", | ||
@@ -16,2 +16,3 @@ "main": "dist/index", | ||
"@nestjs/common": "^9.0.5", | ||
"redis": "^4.2.0", | ||
"rxjs": "^7.5.6" | ||
@@ -18,0 +19,0 @@ }, |
export interface RedisOptions { | ||
api_key:string; | ||
connection_string:string; | ||
} | ||
export const defaultRedisOptions: RedisOptions = { | ||
api_key: '' | ||
connection_string: '' | ||
}; |
@@ -1,2 +0,2 @@ | ||
import { Injectable } from '@nestjs/common'; | ||
import { Injectable, Logger } from '@nestjs/common'; | ||
import { | ||
@@ -6,2 +6,3 @@ defaultRedisOptions, | ||
} from './redis.options'; | ||
import { createClient, RedisClientType } from 'redis'; | ||
@@ -11,3 +12,6 @@ @Injectable() | ||
private options: RedisOptions; | ||
private logger: Logger = new Logger('RedisService'); | ||
public client:RedisClientType; | ||
constructor(options: Partial<RedisOptions>) { | ||
@@ -19,4 +23,24 @@ this.options = Object.assign( | ||
); | ||
this.initialize(); | ||
} | ||
async redisConnect() { | ||
this.client.connect().catch(error => { | ||
this.logger.log(`Redis error on connect: ${error}`); | ||
}) | ||
} | ||
async initialize() { | ||
this.client = createClient({ url: this.options.connection_string }); | ||
this.redisConnect(); | ||
this.client.on('error', async (err) => { | ||
this.logger.log(`Redis error: ${err}`); | ||
await this.client.disconnect(); | ||
this.redisConnect(); | ||
}); | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11367
197
3
1
+ Addedredis@^4.2.0
+ Added@redis/bloom@1.2.0(transitive)
+ Added@redis/client@1.6.0(transitive)
+ Added@redis/graph@1.1.1(transitive)
+ Added@redis/json@1.0.7(transitive)
+ Added@redis/search@1.2.0(transitive)
+ Added@redis/time-series@1.1.0(transitive)
+ Addedcluster-key-slot@1.1.2(transitive)
+ Addedgeneric-pool@3.9.0(transitive)
+ Addedredis@4.7.0(transitive)
+ Addedyallist@4.0.0(transitive)