pr_01m47d24b0e6n91zwymwxg0vpx/apps/web/workers/app.ts

38 lines1,354 bytesCodeBlame

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 attempts1import { createRequestHandler } from "react-router";
2
3const requestHandler = createRequestHandler(
4 () => import("virtual:react-router/server-build"),
5 import.meta.env.MODE,
6);
7
8const GIT_PATH = /\/(info\/refs|git-upload-pack|git-receive-pack)$/;
Docs as their own app; shared theme package9const DOCS = "https://docs.g1t.sh";
Initial g1t: services, event bus, intents and attempts10
Docs as their own app; shared theme package11/** Where the documentation pages that used to live under /docs are now. */
12const 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 footer22
Initial g1t: services, event bus, intents and attempts23export default {
24 async fetch(request, env) {
Docs as their own app; shared theme package25 const { pathname } = new URL(request.url);
Initial g1t: services, event bus, intents and attempts26 // Git over HTTPS shares this hostname but belongs to the repos service.
Docs as their own app; shared theme package27 if (GIT_PATH.test(pathname)) {
Initial g1t: services, event bus, intents and attempts28 return env.REPOS.fetch(request);
29 }
Docs as their own app; shared theme package30 // 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 footer35 }
Initial g1t: services, event bus, intents and attempts36 return requestHandler(request);
37 },
38} satisfies ExportedHandler<Env>;