Diffinery

codician/diffinerypublic

Open-source, agent-first GitHub and GitHub Actions alternative that runs on your own Cloudflare account: git hosting, pull requests, code review and drop-in GitHub Actions YAML on Workers, Durable Objects, R2 and Containers.

38 lines · 1.5 KBRaw History
1/** @jsxImportSource hono/jsx */
2import { Hono } from "hono";
3import type { Env } from "../env.js";
4import type { AppVars } from "../auth/principal.js";
5import { registerAccount } from "./account.js";
6import { registerAuth } from "./auth.js";
7import { registerActions } from "./actions.js";
8import { registerCode } from "./code.js";
9import { registerCollab } from "./collab.js";
10import { registerRepoSettings } from "./repo-settings.js";
11import { registerSeo } from "./seo.js";
12import { errorPage } from "./ui.js";
13import { registerKumoAssets } from "./kumo.js";
14
15/**
16 * Server-rendered web UI. Mount at "/" after the API, Git and runner routes:
17 * it owns `/`, `/login`, `/auth/*`, `/signin/*`, `/new`, `/settings/*`, `/notifications/*`, `/invite/*`, `/-/*`,
18 * `/:owner` and `/:owner/:repo/...` (including `/:owner/:repo/raw/*`).
19 *
20 * Expects the `principal` and `dir` variables to be set by an earlier middleware.
21 * Every POST is CSRF-checked (double-submit cookie, see ./csrf.ts).
22 */
23export const web = new Hono<{ Bindings: Env; Variables: AppVars }>();
24
25web.onError((err, c) => errorPage(c, err));
26
27// Browsers and crawlers ask for these on every origin; keep them off the /:owner route.
28registerSeo(web);
29
30// Order matters: fixed paths (/settings/tokens, /notifications/:id, …) must be
31// registered before the /:owner/:repo patterns they would otherwise match.
32registerKumoAssets(web);
33registerAuth(web);
34registerAccount(web);
35registerRepoSettings(web);
36registerActions(web);
37registerCollab(web);
38registerCode(web);