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.tsxBlame153 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";
79136bbClaude30import webRoutes from "./routes/web";
31
32const app = new Hono();
33
3ef4c9dClaude34// Request context (request ID, start time) runs before everything else
35app.use("*", requestContext);
05b973eClaude36// Middleware — compression first (wraps all responses)
37app.use("*", compress());
38// Logger only on non-git routes to avoid overhead on clone/push
39app.use("*", async (c, next) => {
40 if (c.req.path.includes(".git/")) return next();
41 return logger()(c, next);
42});
79136bbClaude43app.use("/api/*", cors());
3ef4c9dClaude44// Rate-limit API + auth endpoints (generous default)
45app.use("/api/*", rateLimit({ windowMs: 60_000, max: 120 }));
46app.use("/login", rateLimit({ windowMs: 60_000, max: 20 }));
47app.use("/register", rateLimit({ windowMs: 60_000, max: 10 }));
79136bbClaude48
49// Git Smart HTTP protocol routes (must be before web routes)
50app.route("/", gitRoutes);
51
3ef4c9dClaude52// Health + metrics
53app.route("/", healthRoutes);
54
79136bbClaude55// REST API
56app.route("/", apiRoutes);
57
58// Auth routes (register, login, logout)
59app.route("/", authRoutes);
60
61// Settings routes (profile, SSH keys)
62app.route("/", settingsRoutes);
63
c81ab7aClaude64// API tokens
65app.route("/", tokenRoutes);
66
3ef4c9dClaude67// Notifications inbox
68app.route("/", notificationRoutes);
69
70// Dashboard (/dashboard)
71app.route("/", dashboardRoutes);
72
73// AI assistant — /ask + /:owner/:repo/ask
74app.route("/", askRoutes);
75
76// Global search
77app.route("/", searchRoutes);
78
79136bbClaude79// Repo settings (description, visibility, delete)
80app.route("/", repoSettings);
81
c81ab7aClaude82// Webhooks management
83app.route("/", webhookRoutes);
84
79136bbClaude85// Compare view (branch diffs)
86app.route("/", compareRoutes);
87
88// Issue tracker
89app.route("/", issueRoutes);
90
0074234Claude91// Pull requests
92app.route("/", pullRoutes);
93
c81ab7aClaude94// Fork
95app.route("/", forkRoutes);
96
0074234Claude97// Web file editor
98app.route("/", editorRoutes);
99
43de941Claude100// Contributors
101app.route("/", contributorRoutes);
102
3ef4c9dClaude103// Releases
104app.route("/", releaseRoutes);
105
106// Gates (history + settings + branch protection)
107app.route("/", gateRoutes);
108
109// Insights + milestones
110app.route("/", insightsRoutes);
111
c81ab7aClaude112// Explore page
113app.route("/", exploreRoutes);
114
79136bbClaude115// Web UI (catch-all, must be last)
116app.route("/", webRoutes);
117
118// Global 404
119app.notFound((c) => {
120 return c.html(
121 <Layout title="Not Found">
122 <div class="empty-state">
123 <h2>404</h2>
124 <p>Page not found.</p>
125 <a href="/" style="margin-top: 12px; display: inline-block">
126 Go home
127 </a>
128 </div>
129 </Layout>,
130 404
131 );
132});
133
134// Global error handler
135app.onError((err, c) => {
136 console.error("[error]", err);
137 return c.html(
138 <Layout title="Error">
139 <div class="empty-state">
140 <h2>Something went wrong</h2>
141 <p>An unexpected error occurred.</p>
142 {process.env.NODE_ENV !== "production" && (
143 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
144 {err.message}
145 </pre>
146 )}
147 </div>
148 </Layout>,
149 500
150 );
151});
152
153export default app;