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.tsxBlame201 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";
79136bbClaude29import webRoutes from "./routes/web";
59b6fb2Claude30import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
31import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude32
33const app = new Hono();
34
3ef4c9dClaude35// Request context (request ID, start time) runs before everything else
36app.use("*", requestContext);
05b973eClaude37// Middleware — compression first (wraps all responses)
38app.use("*", compress());
39// Logger only on non-git routes to avoid overhead on clone/push
40app.use("*", async (c, next) => {
41 if (c.req.path.includes(".git/")) return next();
42 return logger()(c, next);
43});
79136bbClaude44app.use("/api/*", cors());
3ef4c9dClaude45// Rate-limit API + auth endpoints (generous default)
46app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 }));
47app.use("/login", rateLimit({ windowMs: 60_000, max: 20 }));
48app.use("/register", rateLimit({ windowMs: 60_000, max: 10 }));
79136bbClaude49
59b6fb2Claude50// CSRF protection — set token on all requests, validate on mutations
51app.use("*", csrfToken);
52app.use("*", csrfProtect);
53
45e31d0Claude54// Rate limit auth routes
55app.use("/login", authRateLimit);
56app.use("/register", authRateLimit);
57
59b6fb2Claude58// Rate limit git operations
59app.use("/:owner/:repo.git/*", gitRateLimit);
60
61// Rate limit search
62app.use("/:owner/:repo/search", searchRateLimit);
63app.use("/explore", searchRateLimit);
79136bbClaude64
65// Git Smart HTTP protocol routes (must be before web routes)
66app.route("/", gitRoutes);
67
45e31d0Claude68// REST API v1 (legacy)
79136bbClaude69app.route("/", apiRoutes);
70
ad6d4adClaude71// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
72app.route("/", hookRoutes);
21f8dbdClaude73app.route("/api/events", eventsRoutes);
ad6d4adClaude74
45e31d0Claude75// API documentation
76app.route("/", apiDocsRoutes);
79136bbClaude77
78// Auth routes (register, login, logout)
79app.route("/", authRoutes);
80
81// Settings routes (profile, SSH keys)
82app.route("/", settingsRoutes);
83
7298a17Claude84// 2FA / TOTP settings (Block B4)
85app.route("/", settings2faRoutes);
86
2df1f8cClaude87// WebAuthn / passkey routes (Block B5)
88app.route("/", passkeyRoutes);
89
058d752Claude90// OAuth 2.0 provider (Block B6)
91app.route("/", oauthRoutes);
92app.route("/", developerAppsRoutes);
93
6fc53bdClaude94// Theme toggle (dark/light cookie)
95app.route("/", themeRoutes);
96
97// Audit log UI
98app.route("/", auditRoutes);
99
100// Reactions API (issues, PRs, comments)
101app.route("/", reactionRoutes);
102
24cf2caClaude103// Saved replies (per-user canned comment templates)
104app.route("/", savedReplyRoutes);
105
106// Environments + deployment history UI
107app.route("/", deploymentRoutes);
108
6563f0aClaude109// Organizations + teams (Block B1)
110app.route("/", orgRoutes);
111
c81ab7aClaude112// API tokens
113app.route("/", tokenRoutes);
114
59b6fb2Claude115// Notifications
3ef4c9dClaude116app.route("/", notificationRoutes);
117
59b6fb2Claude118// Organizations
119app.route("/", orgRoutes);
3ef4c9dClaude120
79136bbClaude121// Repo settings (description, visibility, delete)
122app.route("/", repoSettings);
123
c81ab7aClaude124// Webhooks management
125app.route("/", webhookRoutes);
126
79136bbClaude127// Compare view (branch diffs)
128app.route("/", compareRoutes);
129
130// Issue tracker
131app.route("/", issueRoutes);
132
0074234Claude133// Pull requests
134app.route("/", pullRoutes);
135
c81ab7aClaude136// Fork
137app.route("/", forkRoutes);
138
0074234Claude139// Web file editor
140app.route("/", editorRoutes);
141
43de941Claude142// Contributors
143app.route("/", contributorRoutes);
144
2c34075Claude145// Health dashboard
146app.route("/", healthRoutes);
147
16b325cClaude148// Insights (time-travel, dependencies, rollback)
149app.route("/", insightRoutes);
150
f1ab587Claude151// Command center dashboard
152app.route("/", dashboardRoutes);
153
36b4cbdClaude154// Legal pages (terms, privacy, AUP)
155app.route("/", legalRoutes);
156
c81ab7aClaude157// Explore page
158app.route("/", exploreRoutes);
159
59b6fb2Claude160// Onboarding
161app.route("/", onboardingRoutes);
162
79136bbClaude163// Web UI (catch-all, must be last)
164app.route("/", webRoutes);
165
166// Global 404
167app.notFound((c) => {
168 return c.html(
169 <Layout title="Not Found">
170 <div class="empty-state">
171 <h2>404</h2>
172 <p>Page not found.</p>
173 <a href="/" style="margin-top: 12px; display: inline-block">
174 Go home
175 </a>
176 </div>
177 </Layout>,
178 404
179 );
180});
181
182// Global error handler
183app.onError((err, c) => {
184 console.error("[error]", err);
185 return c.html(
186 <Layout title="Error">
187 <div class="empty-state">
188 <h2>Something went wrong</h2>
189 <p>An unexpected error occurred.</p>
190 {process.env.NODE_ENV !== "production" && (
191 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
192 {err.message}
193 </pre>
194 )}
195 </div>
196 </Layout>,
197 500
198 );
199});
200
201export default app;