UNPKG

tezx

Version:

TezX is a high-performance, lightweight JavaScript framework designed for speed, scalability, and flexibility. It enables efficient routing, middleware management, and static file serving with minimal configuration. Fully compatible with Node.js, Deno, an

48 lines (47 loc) โ€ข 1.32 kB
import { Context, Middleware } from "../index.js"; export type CacheRule = { /** * ๐ŸŽฏ Condition to determine if this rule applies. */ condition: (ctx: Context) => boolean; /** * โณ Maximum age (in seconds) for caching. */ maxAge: number; /** * ๐ŸŒ Cache scope: "public" or "private". */ scope: "public" | "private"; /** * ๐Ÿ”„ Enable or disable revalidation with ETag. */ enableETag: boolean; /** * ๐Ÿท๏ธ Vary header for cache variations. */ vary?: string[]; }; export type CacheSettings = Pick<CacheRule, "maxAge" | "scope" | "enableETag" | "vary">; export type CacheOptions = { /** * ๐Ÿงช Weak ETag generation (optional). */ useWeakETag?: boolean; /** * ๐Ÿ“ Logging function for cache events. */ logEvent?: (event: "cached" | "no-cache" | "error", ctx: Context, error?: Error) => void; /** * ๐Ÿ› ๏ธ Default cache settings. */ defaultSettings: CacheSettings; /** * ๐Ÿ”ง Custom rules for dynamic caching behavior. */ rules?: CacheRule[]; }; /** * Middleware to manage HTTP caching headers dynamically. * @param options - Custom options for dynamic caching behavior. */ export declare const cacheControl: (options: CacheOptions) => Middleware;