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

main
ts 33 lines 1.06 KB
Raw
1 import { cloudflare } from "@octanejs/adapter-cloudflare";
2 import { defineConfig, RenderRoute, ServerRoute } from "@octanejs/vite-plugin";
3
4 /**
5 * The Cloudflare request context the adapter forwards as `context.platform`
6 * in production. In dev, Octane's Vite middleware supplies no platform
7 * (upstream limitation), so handlers must tolerate `undefined`.
8 */
9 interface Platform {
10 readonly env?: Record<string, unknown>;
11 readonly ctx?: { readonly waitUntil?: unknown };
12 }
13
14 export default defineConfig({
15 adapter: cloudflare(),
16 router: {
17 routes: [
18 new ServerRoute({
19 path: "/api/hello",
20 methods: ["GET"],
21 handler: (context) => {
22 const platform = context.platform as Platform | undefined;
23 return Response.json({
24 marker: "api-route-ok",
25 secret: (platform?.env?.FIXTURE_SECRET as string | undefined) ?? null,
26 hasWaitUntil: typeof platform?.ctx?.waitUntil === "function",
27 });
28 },
29 }),
30 new RenderRoute({ path: "/", entry: ["App", "/src/App.tsx"] }),
31 ],
32 },
33 });