1// Async (non-Effect) Worker that exercises the native `secrets_store_secret`
2// binding: `/secret` reads `env.SECRET.get()` and echoes the value. Used by
3// the local (dev) test against both the local simulator and, via
4// `Alchemy.remote()`, the remote-proxied live binding.
5interface Env {
6 SECRET: { get(): Promise<string> };
7}
8
9export default {
10 fetch: async (request: Request, env: Env) => {
11 const url = new URL(request.url);
12 if (url.pathname === "/secret") {
13 try {
14 const value = await env.SECRET.get();
15 return Response.json({ value });
16 } catch (e) {
17 return Response.json({ error: (e as Error).message }, { status: 404 });
18 }
19 }
20 return new Response("Not Found", { status: 404 });
21 },
22};