@worker-tools/middleware
Version:
A suite of standalone HTTP server middlewares for Worker Runtimes.
16 lines (15 loc) • 772 B
TypeScript
import type { Temporal } from 'temporal-spec';
import type { Awaitable } from "./utils/common-types.js";
import type { Context } from "./index.js";
import { CacheControl } from '@tusbar/cache-control';
/**
* The Cache-Control HTTP header field holds directives (instructions)
* — in both requests and responses — that control caching in browsers
* and shared caches (e.g. Proxies, CDNs).
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Cache-Control
*/
export declare type CacheOptions = {
[K in keyof CacheControl]: CacheControl[K] extends (number | null | undefined) ? number | Temporal.Duration | null : CacheControl[K];
};
export declare const caching: (options?: CacheOptions) => <X extends Context>(ax: Awaitable<X>) => Promise<X>;