@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 06:00 UTC

main
ts 26 lines 982 Bytes
Raw
1 /**
2 * vinext data-cache adapter builder for Cloudflare KV.
3 *
4 * Cloudflare.Website.Vinext injects this adapter automatically. The runtime factory reads `env.VINEXT_KV_CACHE` (Worker
5 * binding) and uses the same ISR codec as Redis / S3.
6 *
7 * `Website.Vinext` provisions the namespace and seeds prerender pairs
8 * at deploy. Missing binding (local prerender) makes vinext log and
9 * fall back to the in-memory handler.
10 */
11 import { fileURLToPath } from "node:url";
12 import type { KvAdapterOptions } from "./kv-runtime.ts";
13
14 export type { KvAdapterOptions } from "./kv-runtime.ts";
15
16 export const DEFAULT_KV_BINDING = "VINEXT_KV_CACHE";
17
18 export const kvAdapter = (options?: KvAdapterOptions) => {
19 if (options?.binding !== undefined && typeof options.binding !== "string") {
20 throw new TypeError("[vinext] kvAdapter({ binding }) must be a string Worker binding name.");
21 }
22 return {
23 adapter: fileURLToPath(new URL("./kv-runtime.js", import.meta.url)),
24 options,
25 };
26 };