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.tsxBlame199 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";
058d752Claude39import oauthRoutes from "./routes/oauth";
40import developerAppsRoutes from "./routes/developer-apps";
eafe8c6Claude41import workflowRoutes from "./routes/workflows";
79136bbClaude42import webRoutes from "./routes/web";
43
44const app = new Hono();
45
3ef4c9dClaude46// Request context (request ID, start time) runs before everything else
47app.use("*", requestContext);
05b973eClaude48// Middleware — compression first (wraps all responses)
49app.use("*", compress());
50// Logger only on non-git routes to avoid overhead on clone/push
51app.use("*", async (c, next) => {
52 if (c.req.path.includes(".git/")) return next();
53 return logger()(c, next);
54});
79136bbClaude55app.use("/api/*", cors());
3ef4c9dClaude56// Rate-limit API + auth endpoints (generous default)
57app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 }));
58app.use("/login", rateLimit({ windowMs: 60_000, max: 20 }));
59app.use("/register", rateLimit({ windowMs: 60_000, max: 10 }));
79136bbClaude60
61// Git Smart HTTP protocol routes (must be before web routes)
62app.route("/", gitRoutes);
63
3ef4c9dClaude64// Health + metrics
65app.route("/", healthRoutes);
66
ad6d4adClaude67// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
68app.route("/", hookRoutes);
69
79136bbClaude70// REST API
71app.route("/", apiRoutes);
72
73// Auth routes (register, login, logout)
74app.route("/", authRoutes);
75
76// Settings routes (profile, SSH keys)
77app.route("/", settingsRoutes);
78
7298a17Claude79// 2FA / TOTP settings (Block B4)
80app.route("/", settings2faRoutes);
81
2df1f8cClaude82// WebAuthn / passkey routes (Block B5)
83app.route("/", passkeyRoutes);
84
058d752Claude85// OAuth 2.0 provider (Block B6)
86app.route("/", oauthRoutes);
87app.route("/", developerAppsRoutes);
88
6fc53bdClaude89// Theme toggle (dark/light cookie)
90app.route("/", themeRoutes);
91
92// Audit log UI
93app.route("/", auditRoutes);
94
95// Reactions API (issues, PRs, comments)
96app.route("/", reactionRoutes);
97
24cf2caClaude98// Saved replies (per-user canned comment templates)
99app.route("/", savedReplyRoutes);
100
101// Environments + deployment history UI
102app.route("/", deploymentRoutes);
103
6563f0aClaude104// Organizations + teams (Block B1)
105app.route("/", orgRoutes);
106
c81ab7aClaude107// API tokens
108app.route("/", tokenRoutes);
109
3ef4c9dClaude110// Notifications inbox
111app.route("/", notificationRoutes);
112
113// Dashboard (/dashboard)
114app.route("/", dashboardRoutes);
115
116// AI assistant — /ask + /:owner/:repo/ask
117app.route("/", askRoutes);
118
119// Global search
120app.route("/", searchRoutes);
121
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
3ef4c9dClaude146// Releases
147app.route("/", releaseRoutes);
148
149// Gates (history + settings + branch protection)
150app.route("/", gateRoutes);
151
eafe8c6Claude152// Actions-equivalent workflow runner (Block C1)
153app.route("/", workflowRoutes);
154
3ef4c9dClaude155// Insights + milestones
156app.route("/", insightsRoutes);
157
c81ab7aClaude158// Explore page
159app.route("/", exploreRoutes);
160
79136bbClaude161// Web UI (catch-all, must be last)
162app.route("/", webRoutes);
163
164// Global 404
165app.notFound((c) => {
166 return c.html(
167 <Layout title="Not Found">
168 <div class="empty-state">
169 <h2>404</h2>
170 <p>Page not found.</p>
171 <a href="/" style="margin-top: 12px; display: inline-block">
172 Go home
173 </a>
174 </div>
175 </Layout>,
176 404
177 );
178});
179
180// Global error handler
181app.onError((err, c) => {
182 console.error("[error]", err);
183 return c.html(
184 <Layout title="Error">
185 <div class="empty-state">
186 <h2>Something went wrong</h2>
187 <p>An unexpected error occurred.</p>
188 {process.env.NODE_ENV !== "production" && (
189 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
190 {err.message}
191 </pre>
192 )}
193 </div>
194 </Layout>,
195 500
196 );
197});
198
199export default app;