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

main
ts 29 lines 1.06 KB
Raw
1 /**
2 * vinext data-cache adapter builder for S3.
3 *
4 * AWS.Website.Vinext injects this adapter automatically.
5 * The runtime factory reads `CACHE_BUCKET_NAME` from the Lambda
6 * environment (Alchemy's `AWS.Website.Vinext` sets it). The runtime
7 * talks distilled `@distilled.cloud/aws/s3`, the same client
8 * `AWS.S3.GetObject` / `PutObject` wrap.
9 *
10 * If the bucket env is missing (local `vinext start`), vinext logs and
11 * falls back to the in-memory handler.
12 */
13 import { fileURLToPath } from "node:url";
14 import type { S3AdapterOptions } from "./s3-runtime.ts";
15
16 export type { S3AdapterOptions } from "./s3-runtime.ts";
17
18 export const DEFAULT_CACHE_BUCKET_ENV = "CACHE_BUCKET_NAME";
19 export const DEFAULT_CACHE_PREFIX = "vinext-cache/";
20
21 export const s3Adapter = (options?: S3AdapterOptions) => {
22 if (options?.bucketEnv !== undefined && typeof options.bucketEnv !== "string") {
23 throw new TypeError("[vinext] s3Adapter({ bucketEnv }) must be a string env var name.");
24 }
25 return {
26 adapter: fileURLToPath(new URL("./s3-runtime.js", import.meta.url)),
27 options,
28 };
29 };