import type { Context, Middleware } from 'koa'; import type { Memorize } from '../domain/Memorize'; export interface KoaAdapterOptions { /** Time-to-live in milliseconds. Defaults to the global TTL. */ ttl?: number; /** Skip caching for this route. Sets `X-Cache: BYPASS`. */ noCache?: boolean; /** Custom cache key extractor. Defaults to `ctx.originalUrl ?? ctx.url`. */ key?: (ctx: Context) => string; /** Invalidation tags attached to every cached entry. See `deleteByTag`. */ tags?: string[]; } /** * Creates Koa middleware that caches `GET` responses with a `2xx` status code. * * Requires `koa` to be installed as an optional peer dependency. * * @param cache - The {@link Memorize} instance to use as the backing store. * @param options - Optional per-route options. * * @example * ```ts * import Koa from 'koa'; * import Router from '@koa/router'; * import { memorize } from 'express-memorize'; * import { createKoaMiddleware } from 'express-memorize/koa'; * * const app = new Koa(); * const router = new Router(); * const cache = memorize({ ttl: 30_000 }); * * router.get('/users', createKoaMiddleware(cache), async (ctx) => { * ctx.body = await usersService.findAll(); * }); * ``` */ export declare function createKoaMiddleware(cache: Memorize, options?: KoaAdapterOptions): Middleware; //# sourceMappingURL=koa.d.ts.map