Pre-launch — Gluecron is in final validation. Public signups and git hosting for non-owner users open after launch review.
CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
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.tsxBlame205 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";
45e31d0Claude10import apiV2Routes from "./routes/api-v2";
11import apiDocsRoutes from "./routes/api-docs";
79136bbClaude12import authRoutes from "./routes/auth";
13import settingsRoutes from "./routes/settings";
7298a17Claude14import settings2faRoutes from "./routes/settings-2fa";
79136bbClaude15import issueRoutes from "./routes/issues";
16import repoSettings from "./routes/repo-settings";
17import compareRoutes from "./routes/compare";
0074234Claude18import pullRoutes from "./routes/pulls";
19import editorRoutes from "./routes/editor";
c81ab7aClaude20import forkRoutes from "./routes/fork";
21import webhookRoutes from "./routes/webhooks";
22import exploreRoutes from "./routes/explore";
23import tokenRoutes from "./routes/tokens";
43de941Claude24import contributorRoutes from "./routes/contributors";
2c34075Claude25import healthRoutes from "./routes/health";
16b325cClaude26import insightRoutes from "./routes/insights";
f1ab587Claude27import dashboardRoutes from "./routes/dashboard";
36b4cbdClaude28import legalRoutes from "./routes/legal";
bdbd0deClaude29import importRoutes from "./routes/import";
79136bbClaude30import webRoutes from "./routes/web";
59b6fb2Claude31import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
32import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude33
34const app = new Hono();
35
3ef4c9dClaude36// Request context (request ID, start time) runs before everything else
37app.use("*", requestContext);
05b973eClaude38// Middleware — compression first (wraps all responses)
39app.use("*", compress());
40// Logger only on non-git routes to avoid overhead on clone/push
41app.use("*", async (c, next) => {
42 if (c.req.path.includes(".git/")) return next();
43 return logger()(c, next);
44});
79136bbClaude45app.use("/api/*", cors());
3ef4c9dClaude46// Rate-limit API + auth endpoints (generous default)
47app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 }));
48app.use("/login", rateLimit({ windowMs: 60_000, max: 20 }));
49app.use("/register", rateLimit({ windowMs: 60_000, max: 10 }));
79136bbClaude50
59b6fb2Claude51// CSRF protection — set token on all requests, validate on mutations
52app.use("*", csrfToken);
53app.use("*", csrfProtect);
54
45e31d0Claude55// Rate limit auth routes
56app.use("/login", authRateLimit);
57app.use("/register", authRateLimit);
58
59b6fb2Claude59// Rate limit git operations
60app.use("/:owner/:repo.git/*", gitRateLimit);
61
62// Rate limit search
63app.use("/:owner/:repo/search", searchRateLimit);
64app.use("/explore", searchRateLimit);
79136bbClaude65
66// Git Smart HTTP protocol routes (must be before web routes)
67app.route("/", gitRoutes);
68
45e31d0Claude69// REST API v1 (legacy)
79136bbClaude70app.route("/", apiRoutes);
71
ad6d4adClaude72// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
73app.route("/", hookRoutes);
21f8dbdClaude74app.route("/api/events", eventsRoutes);
ad6d4adClaude75
45e31d0Claude76// API documentation
77app.route("/", apiDocsRoutes);
79136bbClaude78
79// Auth routes (register, login, logout)
80app.route("/", authRoutes);
81
82// Settings routes (profile, SSH keys)
83app.route("/", settingsRoutes);
84
7298a17Claude85// 2FA / TOTP settings (Block B4)
86app.route("/", settings2faRoutes);
87
2df1f8cClaude88// WebAuthn / passkey routes (Block B5)
89app.route("/", passkeyRoutes);
90
058d752Claude91// OAuth 2.0 provider (Block B6)
92app.route("/", oauthRoutes);
93app.route("/", developerAppsRoutes);
94
6fc53bdClaude95// Theme toggle (dark/light cookie)
96app.route("/", themeRoutes);
97
98// Audit log UI
99app.route("/", auditRoutes);
100
101// Reactions API (issues, PRs, comments)
102app.route("/", reactionRoutes);
103
24cf2caClaude104// Saved replies (per-user canned comment templates)
105app.route("/", savedReplyRoutes);
106
107// Environments + deployment history UI
108app.route("/", deploymentRoutes);
109
6563f0aClaude110// Organizations + teams (Block B1)
111app.route("/", orgRoutes);
112
c81ab7aClaude113// API tokens
114app.route("/", tokenRoutes);
115
59b6fb2Claude116// Notifications
3ef4c9dClaude117app.route("/", notificationRoutes);
118
59b6fb2Claude119// Organizations
120app.route("/", orgRoutes);
3ef4c9dClaude121
79136bbClaude122// Repo settings (description, visibility, delete)
123app.route("/", repoSettings);
124
c81ab7aClaude125// Webhooks management
126app.route("/", webhookRoutes);
127
79136bbClaude128// Compare view (branch diffs)
129app.route("/", compareRoutes);
130
131// Issue tracker
132app.route("/", issueRoutes);
133
0074234Claude134// Pull requests
135app.route("/", pullRoutes);
136
c81ab7aClaude137// Fork
138app.route("/", forkRoutes);
139
0074234Claude140// Web file editor
141app.route("/", editorRoutes);
142
43de941Claude143// Contributors
144app.route("/", contributorRoutes);
145
2c34075Claude146// Health dashboard
147app.route("/", healthRoutes);
148
16b325cClaude149// Insights (time-travel, dependencies, rollback)
150app.route("/", insightRoutes);
151
f1ab587Claude152// Command center dashboard
153app.route("/", dashboardRoutes);
154
36b4cbdClaude155// Legal pages (terms, privacy, AUP)
156app.route("/", legalRoutes);
157
bdbd0deClaude158// GitHub import / migration
159app.route("/", importRoutes);
160
c81ab7aClaude161// Explore page
162app.route("/", exploreRoutes);
163
59b6fb2Claude164// Onboarding
165app.route("/", onboardingRoutes);
166
79136bbClaude167// Web UI (catch-all, must be last)
168app.route("/", webRoutes);
169
170// Global 404
171app.notFound((c) => {
172 return c.html(
173 <Layout title="Not Found">
174 <div class="empty-state">
175 <h2>404</h2>
176 <p>Page not found.</p>
177 <a href="/" style="margin-top: 12px; display: inline-block">
178 Go home
179 </a>
180 </div>
181 </Layout>,
182 404
183 );
184});
185
186// Global error handler
187app.onError((err, c) => {
188 console.error("[error]", err);
189 return c.html(
190 <Layout title="Error">
191 <div class="empty-state">
192 <h2>Something went wrong</h2>
193 <p>An unexpected error occurred.</p>
194 {process.env.NODE_ENV !== "production" && (
195 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
196 {err.message}
197 </pre>
198 )}
199 </div>
200 </Layout>,
201 500
202 );
203});
204
205export default app;