@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 21 lines 797 Bytes
Raw
1 // NOTE: a top-level `import { env } from "cloudflare:workers"` works too —
2 // SSG runs inside workerd via the cloudflare vite plugin's preview mode (see
3 // src/pages/ssg-env.tsx, which exercises exactly that). This guarded
4 // dynamic-import variant (the same trick waku's own adapter uses) is kept as
5 // the portable pattern for modules that must also load outside a Cloudflare
6 // environment.
7 const DO_NOT_BUNDLE = "";
8
9 export async function readEnv(): Promise<Record<string, unknown>> {
10 try {
11 const mod = await import(/* @vite-ignore */ DO_NOT_BUNDLE + "cloudflare:workers");
12 return mod.env as Record<string, unknown>;
13 } catch {
14 return {};
15 }
16 }
17
18 export async function readMessage(): Promise<string> {
19 const env = await readEnv();
20 return String(env.MESSAGE ?? "unset");
21 }