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.tsxBlame157 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";
12import issueRoutes from "./routes/issues";
13import repoSettings from "./routes/repo-settings";
14import compareRoutes from "./routes/compare";
0074234Claude15import pullRoutes from "./routes/pulls";
16import editorRoutes from "./routes/editor";
c81ab7aClaude17import forkRoutes from "./routes/fork";
18import webhookRoutes from "./routes/webhooks";
19import exploreRoutes from "./routes/explore";
20import tokenRoutes from "./routes/tokens";
43de941Claude21import contributorRoutes from "./routes/contributors";
3ef4c9dClaude22import notificationRoutes from "./routes/notifications";
23import dashboardRoutes from "./routes/dashboard";
24import askRoutes from "./routes/ask";
25import releaseRoutes from "./routes/releases";
26import gateRoutes from "./routes/gates";
27import insightsRoutes from "./routes/insights";
28import searchRoutes from "./routes/search";
29import healthRoutes from "./routes/health";
ad6d4adClaude30import hookRoutes from "./routes/hooks";
79136bbClaude31import webRoutes from "./routes/web";
32
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
50// Git Smart HTTP protocol routes (must be before web routes)
51app.route("/", gitRoutes);
52
3ef4c9dClaude53// Health + metrics
54app.route("/", healthRoutes);
55
ad6d4adClaude56// Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs)
57app.route("/", hookRoutes);
58
79136bbClaude59// REST API
60app.route("/", apiRoutes);
61
62// Auth routes (register, login, logout)
63app.route("/", authRoutes);
64
65// Settings routes (profile, SSH keys)
66app.route("/", settingsRoutes);
67
c81ab7aClaude68// API tokens
69app.route("/", tokenRoutes);
70
3ef4c9dClaude71// Notifications inbox
72app.route("/", notificationRoutes);
73
74// Dashboard (/dashboard)
75app.route("/", dashboardRoutes);
76
77// AI assistant — /ask + /:owner/:repo/ask
78app.route("/", askRoutes);
79
80// Global search
81app.route("/", searchRoutes);
82
79136bbClaude83// Repo settings (description, visibility, delete)
84app.route("/", repoSettings);
85
c81ab7aClaude86// Webhooks management
87app.route("/", webhookRoutes);
88
79136bbClaude89// Compare view (branch diffs)
90app.route("/", compareRoutes);
91
92// Issue tracker
93app.route("/", issueRoutes);
94
0074234Claude95// Pull requests
96app.route("/", pullRoutes);
97
c81ab7aClaude98// Fork
99app.route("/", forkRoutes);
100
0074234Claude101// Web file editor
102app.route("/", editorRoutes);
103
43de941Claude104// Contributors
105app.route("/", contributorRoutes);
106
3ef4c9dClaude107// Releases
108app.route("/", releaseRoutes);
109
110// Gates (history + settings + branch protection)
111app.route("/", gateRoutes);
112
113// Insights + milestones
114app.route("/", insightsRoutes);
115
c81ab7aClaude116// Explore page
117app.route("/", exploreRoutes);
118
79136bbClaude119// Web UI (catch-all, must be last)
120app.route("/", webRoutes);
121
122// Global 404
123app.notFound((c) => {
124 return c.html(
125 <Layout title="Not Found">
126 <div class="empty-state">
127 <h2>404</h2>
128 <p>Page not found.</p>
129 <a href="/" style="margin-top: 12px; display: inline-block">
130 Go home
131 </a>
132 </div>
133 </Layout>,
134 404
135 );
136});
137
138// Global error handler
139app.onError((err, c) => {
140 console.error("[error]", err);
141 return c.html(
142 <Layout title="Error">
143 <div class="empty-state">
144 <h2>Something went wrong</h2>
145 <p>An unexpected error occurred.</p>
146 {process.env.NODE_ENV !== "production" && (
147 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
148 {err.message}
149 </pre>
150 )}
151 </div>
152 </Layout>,
153 500
154 );
155});
156
157export default app;