From 2947344c3c2bdce771ff3d0c815261a48d9a9148 Mon Sep 17 00:00:00 2001 From: Aleksei Androsov Date: Tue, 3 Dec 2024 17:01:33 +0300 Subject: [PATCH] Use LoggerInterface from de (#8) Update events types --- index.ts | 13 +++---------- package-lock.json | 10 +++++----- package.json | 2 +- 3 files changed, 9 insertions(+), 16 deletions(-) diff --git a/index.ts b/index.ts index 2c389f8..1511eef 100644 --- a/index.ts +++ b/index.ts @@ -1,5 +1,5 @@ import { hash } from 'node:crypto'; -import type { CacheInterface } from 'descript'; +import type { CacheInterface, LoggerInterface } from 'descript'; import { error as deError } from 'descript'; import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'; import { Cluster, Redis } from 'ioredis'; @@ -21,9 +21,7 @@ interface InnerOptions extends Options { readTimeout: number; } -interface Logger { - log(event: LoggerEvent): void; -} +type Logger = LoggerInterface; interface Timers { start: number; @@ -35,10 +33,6 @@ export type LoggerEvent = ( type: EVENT.REDIS_CACHE_INITIALIZED; options: Options } | - { - type: EVENT.REDIS_CACHE_ERROR; - error: Error; - } | { type: EVENT.REDIS_CACHE_READ_START; key: string; @@ -93,7 +87,7 @@ export type LoggerEvent = ( } | { type: EVENT.REDIS_CACHE_WRITE_ERROR; - error: unknown; + error: Error; key: string; normalizedKey: string; timers: Timers @@ -355,7 +349,6 @@ export class Cache implements CacheInterface { export enum EVENT { REDIS_CACHE_INITIALIZED= 'REDIS_CACHE_INITIALIZED', - REDIS_CACHE_ERROR= 'REDIS_CACHE_ERROR', REDIS_CACHE_JSON_PARSING_FAILED = 'REDIS_CACHE_JSON_PARSING_FAILED', REDIS_CACHE_JSON_STRINGIFY_FAILED = 'REDIS_CACHE_JSON_STRINGIFY_FAILED', diff --git a/package-lock.json b/package-lock.json index 7b85921..68bb4d3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "@stylistic/eslint-plugin-ts": "^2.11.0", "@types/eslint__js": "^8.42.3", "@types/node": "^22.10.0", - "descript": "^4.0.5", + "descript": "^4.0.6", "eslint": "^9.15.0", "typescript": "^5.7.2", "typescript-eslint": "^8.16.0", @@ -1880,16 +1880,16 @@ } }, "node_modules/descript": { - "version": "4.0.5", - "resolved": "https://registry.npmjs.org/descript/-/descript-4.0.5.tgz", - "integrity": "sha512-OX6Lx0Md8LbTmN5ONsRdjPXowNP/cJYwA8Q0K9Gxvaid4hLxgHTc+xZKy5c0Qs4wOMGyiO7Wfv2/IEgmRP4bTg==", + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/descript/-/descript-4.0.6.tgz", + "integrity": "sha512-IgLSbbUFumGcdR7eMXkbvWjSlMcy5mebrlOtJHarQxOxTaGv+xaEWylHK4dZEiq6BM9J1yLYejdcCHhzT+xbEg==", "dev": true, "license": "MIT", "dependencies": { "@fengkx/zstd-napi": "^0.1.0" }, "engines": { - "node": "*" + "node": ">=18" } }, "node_modules/es-module-lexer": { diff --git a/package.json b/package.json index 2a71f20..d3eff8a 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ "@stylistic/eslint-plugin-ts": "^2.11.0", "@types/eslint__js": "^8.42.3", "@types/node": "^22.10.0", - "descript": "^4.0.5", + "descript": "^4.0.6", "eslint": "^9.15.0", "typescript": "^5.7.2", "typescript-eslint": "^8.16.0",