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.tsxBlame144 lines · 1 contributor
79136bbClaude1import { Hono } from "hono";
2import { logger } from "hono/logger";
3import { cors } from "hono/cors";
4import { Layout } from "./views/layout";
5import gitRoutes from "./routes/git";
6import apiRoutes from "./routes/api";
45e31d0Claude7import apiV2Routes from "./routes/api-v2";
8import apiDocsRoutes from "./routes/api-docs";
79136bbClaude9import authRoutes from "./routes/auth";
10import settingsRoutes from "./routes/settings";
11import issueRoutes from "./routes/issues";
12import repoSettings from "./routes/repo-settings";
13import compareRoutes from "./routes/compare";
0074234Claude14import pullRoutes from "./routes/pulls";
15import editorRoutes from "./routes/editor";
c81ab7aClaude16import forkRoutes from "./routes/fork";
17import webhookRoutes from "./routes/webhooks";
18import exploreRoutes from "./routes/explore";
19import tokenRoutes from "./routes/tokens";
43de941Claude20import contributorRoutes from "./routes/contributors";
59b6fb2Claude21import notificationRoutes from "./routes/notifications";
22import orgRoutes from "./routes/orgs";
23import onboardingRoutes from "./routes/onboarding";
79136bbClaude24import webRoutes from "./routes/web";
59b6fb2Claude25import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit";
26import { csrfToken, csrfProtect } from "./middleware/csrf";
79136bbClaude27
28const app = new Hono();
29
30// Middleware
31app.use("*", logger());
32app.use("/api/*", cors());
33
59b6fb2Claude34// CSRF protection — set token on all requests, validate on mutations
35app.use("*", csrfToken);
36app.use("*", csrfProtect);
37
45e31d0Claude38// Rate limit auth routes
39app.use("/login", authRateLimit);
40app.use("/register", authRateLimit);
41
59b6fb2Claude42// Rate limit git operations
43app.use("/:owner/:repo.git/*", gitRateLimit);
44
45// Rate limit search
46app.use("/:owner/:repo/search", searchRateLimit);
47app.use("/explore", searchRateLimit);
48
79136bbClaude49// Git Smart HTTP protocol routes (must be before web routes)
50app.route("/", gitRoutes);
51
45e31d0Claude52// REST API v1 (legacy)
79136bbClaude53app.route("/", apiRoutes);
54
45e31d0Claude55// REST API v2 (comprehensive, token-authenticated)
56app.route("/", apiV2Routes);
57
58// API documentation
59app.route("/", apiDocsRoutes);
60
79136bbClaude61// Auth routes (register, login, logout)
62app.route("/", authRoutes);
63
64// Settings routes (profile, SSH keys)
65app.route("/", settingsRoutes);
66
c81ab7aClaude67// API tokens
68app.route("/", tokenRoutes);
69
59b6fb2Claude70// Notifications
71app.route("/", notificationRoutes);
72
73// Organizations
74app.route("/", orgRoutes);
75
79136bbClaude76// Repo settings (description, visibility, delete)
77app.route("/", repoSettings);
78
c81ab7aClaude79// Webhooks management
80app.route("/", webhookRoutes);
81
79136bbClaude82// Compare view (branch diffs)
83app.route("/", compareRoutes);
84
85// Issue tracker
86app.route("/", issueRoutes);
87
0074234Claude88// Pull requests
89app.route("/", pullRoutes);
90
c81ab7aClaude91// Fork
92app.route("/", forkRoutes);
93
0074234Claude94// Web file editor
95app.route("/", editorRoutes);
96
43de941Claude97// Contributors
98app.route("/", contributorRoutes);
99
c81ab7aClaude100// Explore page
101app.route("/", exploreRoutes);
102
59b6fb2Claude103// Onboarding
104app.route("/", onboardingRoutes);
105
79136bbClaude106// Web UI (catch-all, must be last)
107app.route("/", webRoutes);
108
109// Global 404
110app.notFound((c) => {
111 return c.html(
112 <Layout title="Not Found">
113 <div class="empty-state">
114 <h2>404</h2>
115 <p>Page not found.</p>
116 <a href="/" style="margin-top: 12px; display: inline-block">
117 Go home
118 </a>
119 </div>
120 </Layout>,
121 404
122 );
123});
124
125// Global error handler
126app.onError((err, c) => {
127 console.error("[error]", err);
128 return c.html(
129 <Layout title="Error">
130 <div class="empty-state">
131 <h2>Something went wrong</h2>
132 <p>An unexpected error occurred.</p>
133 {process.env.NODE_ENV !== "production" && (
134 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
135 {err.message}
136 </pre>
137 )}
138 </div>
139 </Layout>,
140 500
141 );
142});
143
144export default app;