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.tsxBlame120 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";
79136bbClaude21import webRoutes from "./routes/web";
45e31d0Claude22import { authRateLimit } from "./middleware/rate-limit";
79136bbClaude23
24const app = new Hono();
25
26// Middleware
27app.use("*", logger());
28app.use("/api/*", cors());
29
45e31d0Claude30// Rate limit auth routes
31app.use("/login", authRateLimit);
32app.use("/register", authRateLimit);
33
79136bbClaude34// Git Smart HTTP protocol routes (must be before web routes)
35app.route("/", gitRoutes);
36
45e31d0Claude37// REST API v1 (legacy)
79136bbClaude38app.route("/", apiRoutes);
39
45e31d0Claude40// REST API v2 (comprehensive, token-authenticated)
41app.route("/", apiV2Routes);
42
43// API documentation
44app.route("/", apiDocsRoutes);
45
79136bbClaude46// Auth routes (register, login, logout)
47app.route("/", authRoutes);
48
49// Settings routes (profile, SSH keys)
50app.route("/", settingsRoutes);
51
c81ab7aClaude52// API tokens
53app.route("/", tokenRoutes);
54
79136bbClaude55// Repo settings (description, visibility, delete)
56app.route("/", repoSettings);
57
c81ab7aClaude58// Webhooks management
59app.route("/", webhookRoutes);
60
79136bbClaude61// Compare view (branch diffs)
62app.route("/", compareRoutes);
63
64// Issue tracker
65app.route("/", issueRoutes);
66
0074234Claude67// Pull requests
68app.route("/", pullRoutes);
69
c81ab7aClaude70// Fork
71app.route("/", forkRoutes);
72
0074234Claude73// Web file editor
74app.route("/", editorRoutes);
75
43de941Claude76// Contributors
77app.route("/", contributorRoutes);
78
c81ab7aClaude79// Explore page
80app.route("/", exploreRoutes);
81
79136bbClaude82// Web UI (catch-all, must be last)
83app.route("/", webRoutes);
84
85// Global 404
86app.notFound((c) => {
87 return c.html(
88 <Layout title="Not Found">
89 <div class="empty-state">
90 <h2>404</h2>
91 <p>Page not found.</p>
92 <a href="/" style="margin-top: 12px; display: inline-block">
93 Go home
94 </a>
95 </div>
96 </Layout>,
97 404
98 );
99});
100
101// Global error handler
102app.onError((err, c) => {
103 console.error("[error]", err);
104 return c.html(
105 <Layout title="Error">
106 <div class="empty-state">
107 <h2>Something went wrong</h2>
108 <p>An unexpected error occurred.</p>
109 {process.env.NODE_ENV !== "production" && (
110 <pre style="margin-top: 16px; text-align: left; font-size: 12px; color: var(--red)">
111 {err.message}
112 </pre>
113 )}
114 </div>
115 </Layout>,
116 500
117 );
118});
119
120export default app;