Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@

import eslint from '@eslint/js';
import tseslint from 'typescript-eslint';
import stylisticTs from '@stylistic/eslint-plugin-ts';
import stylistic from '@stylistic/eslint-plugin';

export default tseslint.config(
eslint.configs.recommended,
...tseslint.configs.recommended,
...tseslint.configs.stylistic,
{
plugins: {
'@stylistic/ts': stylisticTs,
'@stylistic': stylistic,
},
rules: {
'no-console': 'error',
'@typescript-eslint/consistent-type-imports': [ 'error' ],
'@stylistic/ts/comma-dangle': [ 'error', 'always-multiline' ],
'@stylistic/ts/indent': [ 'error', 4 ],
'@stylistic/ts/object-curly-spacing': [ 'error', 'always' ],
'@stylistic/ts/quote-props': [ 'error', 'as-needed', {
'@stylistic/comma-dangle': [ 'error', 'always-multiline' ],
'@stylistic/indent': [ 'error', 4 ],
'@stylistic/object-curly-spacing': [ 'error', 'always' ],
'@stylistic/quote-props': [ 'error', 'as-needed', {
keywords: true,
numbers: true,
} ],
'@stylistic/ts/quotes': [ 'error', 'single', {
allowTemplateLiterals: true,
'@stylistic/quotes': [ 'error', 'single', {
allowTemplateLiterals: 'always',
} ],
'@stylistic/ts/semi': [ 'error', 'always' ],
'@stylistic/semi': [ 'error', 'always' ],
},
},
);
48 changes: 24 additions & 24 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,76 +32,76 @@ interface Timers {

export type LoggerEvent = (
{
type: EVENT.REDIS_CACHE_INITIALIZED;
'type': EVENT.REDIS_CACHE_INITIALIZED;
options: Options
} |
{
type: EVENT.REDIS_CACHE_READ_START;
'type': EVENT.REDIS_CACHE_READ_START;
key: string;
normalizedKey: string
} |
{
type: EVENT.REDIS_CACHE_READ_KEY_NOT_FOUND;
'type': EVENT.REDIS_CACHE_READ_KEY_NOT_FOUND;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_READ_TIMEOUT;
'type': EVENT.REDIS_CACHE_READ_TIMEOUT;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_READ_ERROR;
'type': EVENT.REDIS_CACHE_READ_ERROR;
error: Error;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_JSON_PARSING_FAILED;
'type': EVENT.REDIS_CACHE_JSON_PARSING_FAILED;
data: unknown;
error: unknown;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_READ_DONE;
'type': EVENT.REDIS_CACHE_READ_DONE;
data: unknown;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_WRITE_START;
'type': EVENT.REDIS_CACHE_WRITE_START;
key: string;
normalizedKey: string
} |
{
type: EVENT.REDIS_CACHE_JSON_STRINGIFY_FAILED;
'type': EVENT.REDIS_CACHE_JSON_STRINGIFY_FAILED;
data: unknown;
error: unknown;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_WRITE_ERROR;
'type': EVENT.REDIS_CACHE_WRITE_ERROR;
error: Error;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_WRITE_FAILED;
'type': EVENT.REDIS_CACHE_WRITE_FAILED;
key: string;
normalizedKey: string;
timers: Timers
} |
{
type: EVENT.REDIS_CACHE_WRITE_DONE;
'type': EVENT.REDIS_CACHE_WRITE_DONE;
data: string;
key: string;
normalizedKey: string;
Expand Down Expand Up @@ -153,7 +153,7 @@ export class Cache<Result> implements CacheInterface<Result> {
}

this.#log({
type: EVENT.REDIS_CACHE_INITIALIZED,
'type': EVENT.REDIS_CACHE_INITIALIZED,
options: { ...this.#options },
});
}
Expand All @@ -170,7 +170,7 @@ export class Cache<Result> implements CacheInterface<Result> {

return new Promise((resolve, reject) => {
this.#log({
type: EVENT.REDIS_CACHE_READ_START,
'type': EVENT.REDIS_CACHE_READ_START,
key,
normalizedKey,
});
Expand All @@ -182,7 +182,7 @@ export class Cache<Result> implements CacheInterface<Result> {
isTimeout = true;

this.#log({
type: EVENT.REDIS_CACHE_READ_TIMEOUT,
'type': EVENT.REDIS_CACHE_READ_TIMEOUT,
key,
normalizedKey,
timers: {
Expand All @@ -205,7 +205,7 @@ export class Cache<Result> implements CacheInterface<Result> {

if (error) {
this.#log({
type: EVENT.REDIS_CACHE_READ_ERROR,
'type': EVENT.REDIS_CACHE_READ_ERROR,
error,
key,
normalizedKey,
Expand All @@ -220,7 +220,7 @@ export class Cache<Result> implements CacheInterface<Result> {
}));
} else if (!data) {
this.#log({
type: EVENT.REDIS_CACHE_READ_KEY_NOT_FOUND,
'type': EVENT.REDIS_CACHE_READ_KEY_NOT_FOUND,
key,
normalizedKey,
timers: {
Expand All @@ -238,7 +238,7 @@ export class Cache<Result> implements CacheInterface<Result> {
parsedValue = JSON.parse(data);
} catch (error) {
this.#log({
type: EVENT.REDIS_CACHE_JSON_PARSING_FAILED,
'type': EVENT.REDIS_CACHE_JSON_PARSING_FAILED,
data,
error,
key,
Expand All @@ -256,7 +256,7 @@ export class Cache<Result> implements CacheInterface<Result> {
}

this.#log({
type: EVENT.REDIS_CACHE_READ_DONE,
'type': EVENT.REDIS_CACHE_READ_DONE,
data,
key,
normalizedKey,
Expand All @@ -282,7 +282,7 @@ export class Cache<Result> implements CacheInterface<Result> {

return new Promise<void>((resolve, reject) => {
this.#log({
type: EVENT.REDIS_CACHE_WRITE_START,
'type': EVENT.REDIS_CACHE_WRITE_START,
key,
normalizedKey,
});
Expand All @@ -292,7 +292,7 @@ export class Cache<Result> implements CacheInterface<Result> {
json = JSON.stringify(value);
} catch (error) {
this.#log({
type: EVENT.REDIS_CACHE_JSON_STRINGIFY_FAILED,
'type': EVENT.REDIS_CACHE_JSON_STRINGIFY_FAILED,
data: value,
error,
key,
Expand All @@ -312,7 +312,7 @@ export class Cache<Result> implements CacheInterface<Result> {
this.#writer.set(normalizedKey, json, 'EX', maxage, (error, done) => {
if (error) {
this.#log({
type: EVENT.REDIS_CACHE_WRITE_ERROR,
'type': EVENT.REDIS_CACHE_WRITE_ERROR,
error,
key,
normalizedKey,
Expand All @@ -326,7 +326,7 @@ export class Cache<Result> implements CacheInterface<Result> {
}));
} else if (!done) {
this.#log({
type: EVENT.REDIS_CACHE_WRITE_FAILED,
'type': EVENT.REDIS_CACHE_WRITE_FAILED,
key,
normalizedKey,
timers: {
Expand All @@ -339,7 +339,7 @@ export class Cache<Result> implements CacheInterface<Result> {
}));
} else {
this.#log({
type: EVENT.REDIS_CACHE_WRITE_DONE,
'type': EVENT.REDIS_CACHE_WRITE_DONE,
data: json,
key,
normalizedKey,
Expand Down
Loading