import type { NxCache } from './nx-cache.js'; /** * TODO: Buffering the entire request in memory might not scale well with high * concurrency or large payloads. Consider updating the NxCache interface to * support streaming, which allows backpressure and more efficient memory use. */ /** * Creates a http handler that implements the * {@link https://nx.dev/recipes/running-tasks/self-hosted-caching#open-api-specification Nx Remote Caching OpenAPI} * for integrating a {@link NxCache custom cache solution}. * * ## Example * * ```ts * import { createServer } from 'http'; * import { * nxHttpCacheHandler, * NxCache, * } from '@robby-rabbitman/nx-plus-nx-http-cache'; * * // TODO: make sure to implement your caching solution * class MyCache implements NxCache { * get: (hash: string) => Promise; * has: (hash: string) => Promise; * set: (hash: string, data: Buffer) => Promise; * } * * const server = createServer( * nxHttpCacheHandler(new MyCache(), { * readAccessToken: 'my-read-access-token', * writeAccessToken: 'my-write-access-token', * }), * ); * * server.listen(3000); * ``` * * Then * {@link https://nx.dev/recipes/running-tasks/self-hosted-caching#usage-notes configure your nx workspace to use a remote cache} * by setting the following environment variables for the nx cli: * * ```sh * NX_SELF_HOSTED_REMOTE_CACHE_SERVER=http://localhost:3000 * NX_SELF_HOSTED_REMOTE_CACHE_ACCESS_TOKEN=my-read-access-token * ``` */ export declare function nxHttpCacheHandler(cache: NxCache, options: { readAccessToken: string; writeAccessToken: string; }): (req: import("http").IncomingMessage, res: import("http").ServerResponse & { req: import("http").IncomingMessage; }) => Promise; //# sourceMappingURL=nx-http-cache-handler.d.ts.map