| 1 | /** |
| 2 | * /.well-known/g1t.json: where this g1t's parts are (packages/contracts |
| 3 | * src/discovery.ts). The phone app reads it when someone points it at their |
| 4 | * own g1t, so they type only the site's address. The same for everyone and |
| 5 | * public, so any origin may read it. |
| 6 | */ |
| 7 | import { env } from "cloudflare:workers"; |
| 8 | |
| 9 | import type { G1tDiscovery } from "@g1t/contracts/discovery"; |
| 10 | |
| 11 | import type { Route } from "./+types/well-known-g1t"; |
| 12 | import { HOSTED_ADDRESSES } from "../lib/addresses"; |
| 13 | import { addresses } from "../lib/addresses.server"; |
| 14 | |
| 15 | export function loader(_: Route.LoaderArgs) { |
| 16 | const { site, api, mcp } = addresses(); |
| 17 | const settings = env as { PHONE_PUSH?: string }; |
| 18 | const body: G1tDiscovery = { |
| 19 | name: "g1t", |
| 20 | site, |
| 21 | api, |
| 22 | mcp, |
| 23 | hosted: site === HOSTED_ADDRESSES.site, |
| 24 | // Phone pushes go through Expo's push service unless this g1t turned them off (PHONE_PUSH=off). |
| 25 | phone: { chat: true, push: settings.PHONE_PUSH !== "off" }, |
| 26 | }; |
| 27 | return Response.json(body, { |
| 28 | headers: { "cache-control": "public, max-age=300", "access-control-allow-origin": "*" }, |
| 29 | }); |
| 30 | } |