UNPKG

@lucidcms/core

Version:

The core of the Lucid CMS. It's responsible for spinning up the API and serving the CMS.

31 lines (30 loc) 1.77 kB
import { LucidHonoContext, LucidHonoGeneric } from "../../../types/hono.mjs"; import { HttpStaticValues } from "../../kv/cache-keys.mjs"; //#region src/libs/http/middleware/cache.d.ts type CacheOptions = { /** The time-to-live (TTL) for the cached response in seconds. */ttl: number; /** * The mode for generating the cache key. * * - "path-only": only the path is used for the cache key, unless you specify includeHeaders * - "include-query": the query parameters are included in the cache key * - "static": a static key is used for the cache key */ mode: "path-only" | "include-query" | "static"; /** The headers to include in the cache key. */ includeHeaders?: string[]; /** The tags to add the cache key to. */ tags?: string[] | ((c: LucidHonoContext) => string[]); /** Bypasses hash generation and uses a simple string key. Useful for endpoints with no variations. */ staticKey?: HttpStaticValues | ((c: LucidHonoContext) => HttpStaticValues | null); /** * Extra request context to include in the cache key, ie. the resolved tenant. * Return an empty object to leave the key unchanged. Not supported alongside staticKey. */ keyContext?: (c: LucidHonoContext) => Record<string, unknown>; /** Skip both cache reads and writes for request-specific responses. */ bypass?: (c: LucidHonoContext) => boolean; }; /** * Middleware to cache responses based on the request context and options. */ declare const cache: (options: CacheOptions) => import("hono").MiddlewareHandler<LucidHonoGeneric, any, {}, Response & import("hono").TypedResponse<import("hono/utils/types").JSONValue, import("hono/utils/http-status").ContentfulStatusCode, "json">>; //#endregion export { cache as default }; //# sourceMappingURL=cache.d.mts.map