Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesPull RequestsActionsSecurityInsightsSettings
✨ AI
More
Blame · Line-by-line history

app.tsx

Each line is annotated with the commit that last touched it. Click any SHA to jump to that commit and see the surrounding change.

app.tsxBlame189 lines · 1 contributor
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
05b973eClaude4import { compress } from "hono/compress";
79136bbClaude5import { Layout } from "./views/layout";
3ef4c9dClaude6import { requestContext } from "./middleware/request-context";
7import { rateLimit } from "./middleware/rate-limit";
79136bbClaude8import gitRoutes from "./routes/git";
9import apiRoutes from "./routes/api";
10import authRoutes from "./routes/auth";
11import settingsRoutes from "./routes/settings";
7298a17Claude12import settings2faRoutes from "./routes/settings-2fa";
79136bbClaude13import issueRoutes from "./routes/issues";
14import repoSettings from "./routes/repo-settings";
15import compareRoutes from "./routes/compare";
0074234Claude16import pullRoutes from "./routes/pulls";
17import editorRoutes from "./routes/editor";
c81ab7aClaude18import forkRoutes from "./routes/fork";
19import webhookRoutes from "./routes/webhooks";
20import exploreRoutes from "./routes/explore";
21import tokenRoutes from "./routes/tokens";
43de941Claude22import contributorRoutes from "./routes/contributors";
3ef4c9dClaude23import notificationRoutes from "./routes/notifications";
24import dashboardRoutes from "./routes/dashboard";
25import askRoutes from "./routes/ask";
26import releaseRoutes from "./routes/releases";
27import gateRoutes from "./routes/gates";
28import insightsRoutes from "./routes/insights";
29import searchRoutes from "./routes/search";
30import healthRoutes from "./routes/health";
ad6d4adClaude31import hookRoutes from "./routes/hooks";
6fc53bdClaude32import themeRoutes from "./routes/theme";
33import auditRoutes from "./routes/audit";
34import reactionRoutes from "./routes/reactions";
24cf2caClaude35import savedReplyRoutes from "./routes/saved-replies";
36import deploymentRoutes from "./routes/deployments";
6563f0aClaude37import orgRoutes from "./routes/orgs";
2df1f8cClaude38import passkeyRoutes from "./routes/passkeys";
79136bbClaude39import webRoutes from "./routes/web";
40
41const app = new Hono();
42
3ef4c9dClaude43// Request context (request ID, start time) runs before everything else
44app.use("*", requestContext);
05b973eClaude45// Middleware — compression first (wraps all responses)
46app.use("*", compress());
47// Logger only on non-git routes to avoid overhead on clone/push
48app.use("*", async (c, next) => {
49 if (c.req.path.includes(".git/")) return next();
50 return logger()(c, next);
51});
79136bbClaude52app.use("/api/*", cors());
3ef4c9dClaude53// Rate-limit API + auth endpoints (generous default)
54app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 }));
55app.use("/login", rateLimit({ windowMs: 60_000, max: 20 }));
56app.use("/register", rateLimit({ windowMs: 60_000, max: 10 }));
79136bbClaude57
58// Git Smart HTTP protocol routes (must be before web routes)
59app.route("/", gitRoutes);
60
3ef4c9dClaude61// Health + metrics
62app.route("/", healthRoutes);
63
ad6d4adClaude64// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
65app.route("/", hookRoutes);
66
79136bbClaude67// REST API
68app.route("/", apiRoutes);
69
70// Auth routes (register, login, logout)
71app.route("/", authRoutes);
72
73// Settings routes (profile, SSH keys)
74app.route("/", settingsRoutes);
75
7298a17Claude76// 2FA / TOTP settings (Block B4)
77app.route("/", settings2faRoutes);
78
2df1f8cClaude79// WebAuthn / passkey routes (Block B5)
80app.route("/", passkeyRoutes);
81
6fc53bdClaude82// Theme toggle (dark/light cookie)
83app.route("/", themeRoutes);
84
85// Audit log UI
86app.route("/", auditRoutes);
87
88// Reactions API (issues, PRs, comments)
89app.route("/", reactionRoutes);
90
24cf2caClaude91// Saved replies (per-user canned comment templates)
92app.route("/", savedReplyRoutes);
93
94// Environments + deployment history UI
95app.route("/", deploymentRoutes);
96
6563f0aClaude97// Organizations + teams (Block B1)
98app.route("/", orgRoutes);
99
c81ab7aClaude100// API tokens
101app.route("/", tokenRoutes);
102
3ef4c9dClaude103// Notifications inbox
104app.route("/", notificationRoutes);
105
106// Dashboard (/dashboard)
107app.route("/", dashboardRoutes);
108
109// AI assistant — /ask + /:owner/:repo/ask
110app.route("/", askRoutes);
111
112// Global search
113app.route("/", searchRoutes);
114
79136bbClaude115// Repo settings (description, visibility, delete)
116app.route("/", repoSettings);
117
c81ab7aClaude118// Webhooks management
119app.route("/", webhookRoutes);
120
79136bbClaude121// Compare view (branch diffs)
122app.route("/", compareRoutes);
123
124// Issue tracker
125app.route("/", issueRoutes);
126
0074234Claude127// Pull requests
128app.route("/", pullRoutes);
129
c81ab7aClaude130// Fork
131app.route("/", forkRoutes);
132
0074234Claude133// Web file editor
134app.route("/", editorRoutes);
135
43de941Claude136// Contributors
137app.route("/", contributorRoutes);
138
3ef4c9dClaude139// Releases
140app.route("/", releaseRoutes);
141
142// Gates (history + settings + branch protection)
143app.route("/", gateRoutes);
144
145// Insights + milestones
146app.route("/", insightsRoutes);
147
c81ab7aClaude148// Explore page
149app.route("/", exploreRoutes);
150
79136bbClaude151// Web UI (catch-all, must be last)
152app.route("/", webRoutes);
153
154// Global 404
155app.notFound((c) => {
156 return c.html(
157 <Layout title="Not Found">
158 <div class="empty-state">
159 <h2>404</h2>
160 <p>Page not found.</p>
161 <a href="/" style="margin-top: 12px; display: inline-block">
162 Go home
163 </a>
164 </div>
165 </Layout>,
166 404
167 );
168});
169
170// Global error handler
171app.onError((err, c) => {
172 console.error("[error]", err);
173 return c.html(
174 <Layout title="Error">
175 <div class="empty-state">
176 <h2>Something went wrong</h2>
177 <p>An unexpected error occurred.</p>
178 {process.env.NODE_ENV !== "production" && (
179 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
180 {err.message}
181 </pre>
182 )}
183 </div>
184 </Layout>,
185 500
186 );
187});
188
189export default app;