UNPKG

restifyx.js

Version:

Advanced API endpoint handler system with automatic documentation

33 lines (32 loc) 1.02 kB
import type { Request, Response, NextFunction } from "express"; interface CacheOptions { duration: number; keyGenerator?: (req: Request) => string; cacheNullValues?: boolean; cacheErrorResponses?: boolean; maxSize?: number; staleWhileRevalidate?: boolean; } declare class MemoryCache { private cache; private logger; private maxSize; private cleanupInterval; constructor(options?: { maxSize?: number; cleanupInterval?: number; }); set(key: string, value: any, duration: number): void; get(key: string): any | undefined; delete(key: string): void; clear(): void; size(): number; keys(): string[]; has(key: string): boolean; private evictLeastRecentlyUsed; startCleanupInterval(intervalMs: number): void; stopCleanupInterval(): void; } declare const memoryCache: MemoryCache; export declare function cacheMiddleware(options: CacheOptions): (req: Request, res: Response, next: NextFunction) => void; export { memoryCache };