1import * as Cloudflare from "@/Cloudflare/index.ts";
2import * as Effect from "effect/Effect";
3import * as HttpServerResponse from "effect/http/HttpServerResponse";
4
5/**
6 * Worker protected by a **dedicated** Access application declared through
7 * the `access.policies` form — no Application resource in sight. The
8 * application is auto-declared in the Worker's namespace
9 * (`OwnedAccessWorker/Access`).
10 */
11export default class OwnedAccessWorker extends Cloudflare.Worker<OwnedAccessWorker>()(
12 "OwnedAccessWorker",
13 {
14 main: import.meta.url,
15 access: {
16 name: "Access for alchemy owned-app test",
17 // Production traffic only — preview URLs stay open.
18 previews: false,
19 policies: [
20 {
21 decision: "allow",
22 include: [{ emailDomain: "example.com" }],
23 },
24 ],
25 },
26 },
27 Effect.gen(function* () {
28 return {
29 fetch: Effect.gen(function* () {
30 const access = yield* Cloudflare.Access.Context;
31 return yield* HttpServerResponse.json({
32 marker: "alchemy-access-owned-open",
33 authenticated: access !== undefined,
34 });
35 }),
36 };
37 }),
38) {}