| 1 | import * as Context from "effect/Context"; |
| 2 | import { fallbackCf } from "./CfOptions.shared.ts"; |
| 3 | |
| 4 | export * from "./CfOptions.shared.ts"; |
| 5 | |
| 6 | /** |
| 7 | * The `request.cf` object exposed to user workers, defaulting to |
| 8 | * {@link fallbackCf} (Miniflare's static placeholder blob). Override via |
| 9 | * layer to simulate different geolocation or TLS properties: |
| 10 | * |
| 11 | * ```ts |
| 12 | * Layer.succeed(Cf.Cf, { ...Cf.fallbackCf, country: "GB" }) |
| 13 | * ``` |
| 14 | * |
| 15 | * Requests carrying an `MF-CF-Blob` header bypass this value; the header's |
| 16 | * JSON is used verbatim. |
| 17 | */ |
| 18 | export const Cf = Context.Reference("cloudflare-runtime/Cf", { |
| 19 | defaultValue: (): Record<string, unknown> => fallbackCf, |
| 20 | }); |