UNPKG

cf-workers-query

Version:

Automatically cache and revalidate data in Cloudflare Workers. Using the Cache API and Execution Context

13 lines (10 loc) 546 B
import { Handler, Context } from 'hono'; import { a as CreateQuery, Q as QueryKey } from '../create-query-B9ILJCq6.cjs'; type CacheKey = QueryKey | ((ctx: Context) => QueryKey); type CacheOptions = Omit<CreateQuery, 'queryKey' | 'queryFn' | 'throwOnError' | 'revalidate'> & { cacheKey: CacheKey; handler: (ctx: Context) => Response | Promise<Response>; revalidate?: boolean | ((ctx: Context) => boolean); }; declare const cache: <E = {}>({ cacheKey, handler, revalidate, ...options }: CacheOptions) => Handler<E>; export { cache };