import type { Memorize } from '../domain/Memorize'; type FetchHandler = (request: Request) => Promise; export interface FetchAdapterOptions { /** Time-to-live in milliseconds. Defaults to the global TTL. */ ttl?: number; /** Skip caching. Sets `X-Cache: BYPASS`. */ noCache?: boolean; /** Custom cache key extractor. Defaults to `pathname + search`. */ key?: (request: Request) => string; /** Invalidation tags attached to every cached entry. See `deleteByTag`. */ tags?: string[]; } /** * Wraps a Fetch API handler with in-memory caching for `GET` requests with * `2xx` responses. * * Works in any runtime that supports the Web-standard `Request` and `Response` * APIs: Node.js, Bun, Deno, Cloudflare Workers, and similar environments. * * @param cache - The {@link Memorize} instance to use as the backing store. * @param handler - The original fetch handler to wrap. * @param options - Optional per-handler options. * * @example Serverless handler * ```ts * import { memorize } from 'express-memorize'; * import { cacheFetchHandler } from 'express-memorize/fetch'; * * const cache = memorize({ ttl: 30_000 }); * * export default cacheFetchHandler(cache, async (request) => { * const users = await usersService.findAll(); * return Response.json(users); * }); * ``` * * @example With options * ```ts * const handler = cacheFetchHandler(cache, originalHandler, { * ttl: 60_000, * key: (req) => new URL(req.url).pathname, * }); * ``` */ export declare function cacheFetchHandler(cache: Memorize, handler: FetchHandler, options?: FetchAdapterOptions): FetchHandler; export {}; //# sourceMappingURL=fetch.d.ts.map