| 1 | import { counterNamespace, readEnv } from "../env.ts"; |
| 2 | |
| 3 | export default async function HomePage() { |
| 4 | const env = await readEnv(); |
| 5 | const counter = await counterNamespace(); |
| 6 | // SSR reads the DO at request time — proves the namespace binding resolves |
| 7 | // to the Counter class exported by the user's worker entry. |
| 8 | const count = counter ? await counter.getByName("fixture").get() : -1; |
| 9 | return ( |
| 10 | <div> |
| 11 | <div data-testid="page-marker">PAGE_MARKER</div> |
| 12 | <div data-testid="env-message"> |
| 13 | MESSAGE={String(env.MESSAGE ?? "unset")} |
| 14 | </div> |
| 15 | <div data-testid="do-count">COUNT={count}</div> |
| 16 | </div> |
| 17 | ); |
| 18 | } |
| 19 | |
| 20 | // Dynamic so the worker must serve it at request time. |
| 21 | export const getConfig = async () => ({ render: "dynamic" }) as const; |