express-idempotency-redis-adapter
Advanced tools
Comparing version 1.0.6 to 1.0.7
@@ -36,10 +36,11 @@ "use strict"; | ||
const client_1 = require("@redis/client"); | ||
const timeToLive = 86400; | ||
const ttl = 86400; | ||
class RedisAdapter { | ||
constructor({ connectionConfig, connectionInstance, ttl = timeToLive, }) { | ||
constructor(options) { | ||
var _a, _b; | ||
_RedisAdapter_instances.add(this); | ||
_RedisAdapter_ttl.set(this, void 0); | ||
_RedisAdapter_client.set(this, void 0); | ||
__classPrivateFieldSet(this, _RedisAdapter_client, connectionInstance !== null && connectionInstance !== void 0 ? connectionInstance : (0, client_1.createClient)(connectionConfig), "f"); | ||
__classPrivateFieldSet(this, _RedisAdapter_ttl, ttl, "f"); | ||
__classPrivateFieldSet(this, _RedisAdapter_ttl, (_a = options === null || options === void 0 ? void 0 : options.ttl) !== null && _a !== void 0 ? _a : ttl, "f"); | ||
__classPrivateFieldSet(this, _RedisAdapter_client, (_b = options === null || options === void 0 ? void 0 : options.connectionInstance) !== null && _b !== void 0 ? _b : (0, client_1.createClient)(options === null || options === void 0 ? void 0 : options.connectionConfig), "f"); | ||
} | ||
@@ -65,3 +66,7 @@ get isOpen() { | ||
const jsonDump = yield __classPrivateFieldGet(this, _RedisAdapter_client, "f").get(idempotencyKey); | ||
return jsonDump ? JSON.parse(jsonDump) : null; | ||
if (jsonDump) { | ||
const payload = Object.assign({ idempotencyKey }, JSON.parse(jsonDump)); | ||
return payload; | ||
} | ||
return null; | ||
}); | ||
@@ -68,0 +73,0 @@ } |
{ | ||
"name": "express-idempotency-redis-adapter", | ||
"version": "1.0.6", | ||
"version": "1.0.7", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -38,3 +38,5 @@ import { | ||
this.#ttl = options?.ttl ?? ttl; | ||
this.#client = options?.connectionInstance ?? createClient(options?.connectionConfig); | ||
this.#client | ||
= options?.connectionInstance ?? createClient(options?.connectionConfig); | ||
} | ||
@@ -41,0 +43,0 @@ |
@@ -17,3 +17,3 @@ import { type IdempotencyResource, type IIdempotencyDataAdapter } from 'express-idempotency'; | ||
#private; | ||
constructor({ connectionConfig, connectionInstance, ttl, }: RedisAdapterOptions); | ||
constructor(options?: RedisAdapterOptions); | ||
get isOpen(): boolean; | ||
@@ -23,3 +23,7 @@ get isReady(): boolean; | ||
disconnect(): Promise<void>; | ||
findByIdempotencyKey(idempotencyKey: string): Promise<IdempotencyResource | null>; | ||
findByIdempotencyKey(idempotencyKey: string): Promise<{ | ||
request: import("express-idempotency").IdempotencyRequest; | ||
response?: import("express-idempotency").IdempotencyResponse | undefined; | ||
idempotencyKey: string; | ||
} | null>; | ||
create(idempotencyResource: IdempotencyResource): Promise<void>; | ||
@@ -26,0 +30,0 @@ update(idempotencyResource: IdempotencyResource): Promise<void>; |
Sorry, the diff of this file is not supported yet
15521
225