Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Initial g1t: services, event bus, intents and attempts | 1 | import { createRequestHandler } from "react-router"; |
| 2 | ||
| 3 | const requestHandler = createRequestHandler( | |
| 4 | () => import("virtual:react-router/server-build"), | |
| 5 | import.meta.env.MODE, | |
| 6 | ); | |
| 7 | ||
| 8 | const GIT_PATH = /\/(info\/refs|git-upload-pack|git-receive-pack)$/; | |
| Docs as their own app; shared theme package | 9 | const DOCS = "https://docs.g1t.sh"; |
| Initial g1t: services, event bus, intents and attempts | 10 | |
| Docs as their own app; shared theme package | 11 | /** Where the documentation pages that used to live under /docs are now. */ |
| 12 | const MOVED_DOCS: Record<string, string> = { | |
| 13 | "/docs": "/quickstart/", | |
| 14 | "/docs/concepts": "/concepts/overview/", | |
| 15 | "/docs/authentication": "/guides/authentication/", | |
| 16 | "/docs/git": "/guides/git/", | |
| 17 | "/docs/g1t-agents": "/guides/g1t-agents/", | |
| 18 | "/docs/agents": "/guides/bring-your-own-agent/", | |
| 19 | "/docs/api": "/reference/api/", | |
| 20 | "/docs/api/reference": "/api/reference/", | |
| 21 | }; | |
| docs.g1t.sh, generated OpenAPI with an interactive reference, full footer | 22 | |
| Initial g1t: services, event bus, intents and attempts | 23 | export default { |
| 24 | async fetch(request, env) { | |
| Docs as their own app; shared theme package | 25 | const { pathname } = new URL(request.url); |
| Initial g1t: services, event bus, intents and attempts | 26 | // Git over HTTPS shares this hostname but belongs to the repos service. |
| Docs as their own app; shared theme package | 27 | if (GIT_PATH.test(pathname)) { |
| Initial g1t: services, event bus, intents and attempts | 28 | return env.REPOS.fetch(request); |
| 29 | } | |
| Docs as their own app; shared theme package | 30 | // The documentation is its own site. |
| 31 | if (pathname === "/docs" || pathname.startsWith("/docs/")) { | |
| 32 | const page = pathname.endsWith("/") ? pathname.slice(0, -1) : pathname; | |
| 33 | const target = MOVED_DOCS[page] ?? "/"; | |
| 34 | return Response.redirect(DOCS + target, 301); | |
| docs.g1t.sh, generated OpenAPI with an interactive reference, full footer | 35 | } |
| Initial g1t: services, event bus, intents and attempts | 36 | return requestHandler(request); |
| 37 | }, | |
| 38 | } satisfies ExportedHandler<Env>; |