Skip to content

Commit

Permalink
fix(ts): export types that might be useful
Browse files Browse the repository at this point in the history
  • Loading branch information
SkeLLLa committed Apr 25, 2024
1 parent c1b6d28 commit a4800bb
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Redis } from "ioredis";

type StorageOptionsType = "redis" | "memory";
export type StorageOptionsType = "redis" | "memory";

type StorageOptions = {
export type StorageOptions = {
type: StorageOptionsType,
options: StorageRedisOptions | StorageMemoryOptions,
}
Expand All @@ -19,13 +19,13 @@ interface Logger {
warn: (input: LoggerInput) => void;
error: (input: LoggerInput) => void;
}
interface StorageRedisOptions {
export interface StorageRedisOptions {
client: Redis;
log?: Logger;
invalidation?: { referencesTTL: number } | boolean;
}

interface StorageMemoryOptions {
export interface StorageMemoryOptions {
size?: number;
log?: Logger;
invalidation?: boolean;
Expand All @@ -43,17 +43,17 @@ type Events = {
onMiss?: (key: string) => void;
};

type StorageInputRedis = {
export type StorageInputRedis = {
type: "redis";
options?: StorageRedisOptions;
};

type StorageInputMemory = {
export type StorageInputMemory = {
type: "memory";
options?: StorageMemoryOptions;
};

declare class StorageInterface {
export declare class StorageInterface {
constructor(options: any);

get(key: string): Promise<undefined | any>;
Expand All @@ -64,7 +64,7 @@ declare class StorageInterface {
refresh(): Promise<void>;
}

declare function createCache(
export declare function createCache(
options?: {
storage?: StorageInputRedis | StorageInputMemory;
ttl?: number | ((result: unknown) => number);
Expand All @@ -73,7 +73,7 @@ declare function createCache(
} & Events,
): Cache;

declare class Cache {
export declare class Cache {
constructor(
options: {
ttl: number | ((result: unknown) => number);
Expand Down Expand Up @@ -125,11 +125,10 @@ declare class Cache {
): Promise<void>;
}

declare function createStorage(type: "redis", options: StorageRedisOptions): StorageInterface;
declare function createStorage(type: "memory", options: StorageMemoryOptions): StorageInterface;
declare function createStorage(
export declare function createStorage(type: "redis", options: StorageRedisOptions): StorageInterface;
export declare function createStorage(type: "memory", options: StorageMemoryOptions): StorageInterface;
export declare function createStorage(
type: StorageOptionsType,
options: StorageRedisOptions | StorageMemoryOptions,
): StorageInterface;

export { createCache, Cache, createStorage, StorageInterface, StorageMemoryOptions };

0 comments on commit a4800bb

Please sign in to comment.