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.
| 79136bb | 1 | import { Hono } from "hono"; |
| 2 | import { logger } from "hono/logger"; | |
| 3 | import { cors } from "hono/cors"; | |
| 05b973e | 4 | import { compress } from "hono/compress"; |
| c63b860 | 5 | // BLOCK O2 — shared error-page surface (404 / 500 / 403). |
| 6 | import { NotFoundPage, ServerErrorPage } from "./views/error-page"; | |
| 80bed05 | 7 | import { reportError } from "./lib/observability"; |
| 3ef4c9d | 8 | import { requestContext } from "./middleware/request-context"; |
| 9 | import { rateLimit } from "./middleware/rate-limit"; | |
| 79136bb | 10 | import gitRoutes from "./routes/git"; |
| 11 | import apiRoutes from "./routes/api"; | |
| 45e31d0 | 12 | import apiV2Routes from "./routes/api-v2"; |
| 13 | import apiDocsRoutes from "./routes/api-docs"; | |
| 79136bb | 14 | import authRoutes from "./routes/auth"; |
| c63b860 | 15 | import passwordResetRoutes from "./routes/password-reset"; |
| 16 | import emailVerificationRoutes from "./routes/email-verification"; | |
| 79136bb | 17 | import settingsRoutes from "./routes/settings"; |
| 7298a17 | 18 | import settings2faRoutes from "./routes/settings-2fa"; |
| 79136bb | 19 | import issueRoutes from "./routes/issues"; |
| 20 | import repoSettings from "./routes/repo-settings"; | |
| 23d1a81 | 21 | import collaboratorRoutes from "./routes/collaborators"; |
| 04f6b7f | 22 | import teamCollaboratorRoutes from "./routes/team-collaborators"; |
| 23 | import invitesRoutes from "./routes/invites"; | |
| 24 | import liveEventsRoutes from "./routes/live-events"; | |
| 79136bb | 25 | import compareRoutes from "./routes/compare"; |
| 0074234 | 26 | import pullRoutes from "./routes/pulls"; |
| 27 | import editorRoutes from "./routes/editor"; | |
| c81ab7a | 28 | import forkRoutes from "./routes/fork"; |
| 29 | import webhookRoutes from "./routes/webhooks"; | |
| 30 | import exploreRoutes from "./routes/explore"; | |
| 31 | import tokenRoutes from "./routes/tokens"; | |
| 43de941 | 32 | import contributorRoutes from "./routes/contributors"; |
| 699e5c7 | 33 | import healthRoutes from "./routes/health-probe"; |
| 34 | import healthDashboardRoutes from "./routes/health"; | |
| 2316be6 | 35 | import statusRoutes from "./routes/status"; |
| 80bed05 | 36 | import helpRoutes from "./routes/help"; |
| b0148e9 | 37 | import marketingRoutes from "./routes/marketing"; |
| 5f2e749 | 38 | import pricingRoutes from "./routes/pricing"; |
| 5618f9a | 39 | import seoRoutes from "./routes/seo"; |
| 05cdb85 | 40 | import versionRoutes from "./routes/version"; |
| f295f78 | 41 | import { platformStatus } from "./routes/platform-status"; |
| 52ad8b1 | 42 | import publicStatsRoutes from "./routes/public-stats"; |
| 43 | import demoRoutes from "./routes/demo"; | |
| 16b325c | 44 | import insightRoutes from "./routes/insights"; |
| f1ab587 | 45 | import dashboardRoutes from "./routes/dashboard"; |
| 36b4cbd | 46 | import legalRoutes from "./routes/legal"; |
| bdbd0de | 47 | import importRoutes from "./routes/import"; |
| 14c3cc8 | 48 | import importBulkRoutes from "./routes/import-bulk"; |
| 49 | import migrationRoutes from "./routes/migrations"; | |
| 50 | import specsRoutes from "./routes/specs"; | |
| 79136bb | 51 | import webRoutes from "./routes/web"; |
| 0316dbb | 52 | import hookRoutes from "./routes/hooks"; |
| 53 | import eventsRoutes from "./routes/events"; | |
| 54 | import passkeyRoutes from "./routes/passkeys"; | |
| 55 | import oauthRoutes from "./routes/oauth"; | |
| 56 | import developerAppsRoutes from "./routes/developer-apps"; | |
| 57 | import themeRoutes from "./routes/theme"; | |
| 58 | import auditRoutes from "./routes/audit"; | |
| 59 | import reactionRoutes from "./routes/reactions"; | |
| 60 | import savedReplyRoutes from "./routes/saved-replies"; | |
| 61 | import deploymentRoutes from "./routes/deployments"; | |
| 62 | import orgRoutes from "./routes/orgs"; | |
| 63 | import notificationRoutes from "./routes/notifications"; | |
| 64 | import onboardingRoutes from "./routes/onboarding"; | |
| 65 | import adminRoutes from "./routes/admin"; | |
| f764c07 | 66 | import adminDeploysRoutes from "./routes/admin-deploys"; |
| 67 | import adminDeploysPageRoutes from "./routes/admin-deploys-page"; | |
| 0316dbb | 68 | import advisoriesRoutes from "./routes/advisories"; |
| 69 | import aiChangelogRoutes from "./routes/ai-changelog"; | |
| 70 | import aiExplainRoutes from "./routes/ai-explain"; | |
| 71 | import aiTestsRoutes from "./routes/ai-tests"; | |
| 72 | import askRoutes from "./routes/ask"; | |
| 73 | import billingRoutes from "./routes/billing"; | |
| 6778ad2 | 74 | import stripeWebhookRoutes from "./routes/stripe-webhook"; |
| 0316dbb | 75 | import codeScanningRoutes from "./routes/code-scanning"; |
| 76 | import commitStatusesRoutes from "./routes/commit-statuses"; | |
| 77 | import copilotRoutes from "./routes/copilot"; | |
| 78 | import depUpdaterRoutes from "./routes/dep-updater"; | |
| 79 | import depsRoutes from "./routes/deps"; | |
| 80 | import discussionsRoutes from "./routes/discussions"; | |
| 81 | import environmentsRoutes from "./routes/environments"; | |
| 82 | import followsRoutes from "./routes/follows"; | |
| 83 | import gatesRoutes from "./routes/gates"; | |
| 84 | import gistsRoutes from "./routes/gists"; | |
| 85 | import graphqlRoutes from "./routes/graphql"; | |
| 2c2163e | 86 | import mcpRoutes from "./routes/mcp"; |
| 0316dbb | 87 | import marketplaceRoutes from "./routes/marketplace"; |
| 88 | import mergeQueueRoutes from "./routes/merge-queue"; | |
| 89 | import mirrorsRoutes from "./routes/mirrors"; | |
| 90 | import orgInsightsRoutes from "./routes/org-insights"; | |
| 91 | import packagesRoutes from "./routes/packages"; | |
| 92 | import packagesApiRoutes from "./routes/packages-api"; | |
| 93 | import pagesRoutes from "./routes/pages"; | |
| 94 | import projectsRoutes from "./routes/projects"; | |
| 95 | import protectedTagsRoutes from "./routes/protected-tags"; | |
| 96 | import pwaRoutes from "./routes/pwa"; | |
| 46d6165 | 97 | import installRoutes from "./routes/install"; |
| 0316dbb | 98 | import releasesRoutes from "./routes/releases"; |
| 99 | import requiredChecksRoutes from "./routes/required-checks"; | |
| 100 | import rulesetsRoutes from "./routes/rulesets"; | |
| 101 | import searchRoutes from "./routes/search"; | |
| 102 | import semanticSearchRoutes from "./routes/semantic-search"; | |
| 103 | import signingKeysRoutes from "./routes/signing-keys"; | |
| 104 | import sponsorsRoutes from "./routes/sponsors"; | |
| 105 | import ssoRoutes from "./routes/sso"; | |
| 46d6165 | 106 | import githubOauthRoutes from "./routes/github-oauth"; |
| 0316dbb | 107 | import symbolsRoutes from "./routes/symbols"; |
| 108 | import templatesRoutes from "./routes/templates"; | |
| 109 | import trafficRoutes from "./routes/traffic"; | |
| 110 | import wikisRoutes from "./routes/wikis"; | |
| 111 | import workflowsRoutes from "./routes/workflows"; | |
| 5ff9cc2 | 112 | import workflowArtifactsRoutes from "./routes/workflow-artifacts"; |
| 113 | import workflowSecretsRoutes from "./routes/workflow-secrets"; | |
| 46d6165 | 114 | import sleepModeRoutes from "./routes/sleep-mode"; |
| 52ad8b1 | 115 | import vsGithubRoutes from "./routes/vs-github"; |
| 59b6fb2 | 116 | import { authRateLimit, gitRateLimit, searchRateLimit } from "./middleware/rate-limit"; |
| 117 | import { csrfToken, csrfProtect } from "./middleware/csrf"; | |
| 79136bb | 118 | |
| 2316901 | 119 | import type { AuthEnv } from "./middleware/auth"; |
| 120 | ||
| 121 | const app = new Hono<AuthEnv>(); | |
| 79136bb | 122 | |
| 3ef4c9d | 123 | // Request context (request ID, start time) runs before everything else |
| 124 | app.use("*", requestContext); | |
| 05b973e | 125 | // Middleware — compression first (wraps all responses) |
| 126 | app.use("*", compress()); | |
| 127 | // Logger only on non-git routes to avoid overhead on clone/push | |
| 128 | app.use("*", async (c, next) => { | |
| 129 | if (c.req.path.includes(".git/")) return next(); | |
| 130 | return logger()(c, next); | |
| 131 | }); | |
| 79136bb | 132 | app.use("/api/*", cors()); |
| 290ea77 | 133 | |
| 36cc17a | 134 | // Force-revalidate HTML on every request — kills browser cache holding stale |
| 290ea77 | 135 | // pre-redesign markup. JSON / static assets keep their own cache rules; only |
| 136 | // text/html responses get the no-cache stamp. Without this, every push to | |
| 137 | // main left users staring at cached 80s-looking pages from before the design | |
| 138 | // landed. | |
| 36cc17a | 139 | // |
| 140 | // We deliberately use `private, no-cache, must-revalidate` rather than | |
| 141 | // `no-store`. `no-store` disables Safari/Chrome's back-forward cache (bfcache), | |
| 142 | // which makes every Back/Forward press a cold server round-trip — that | |
| 143 | // contributed to the "every nav feels like a fresh login" UX complaint. | |
| 144 | // `no-cache` still revalidates on direct fetch but lets bfcache hold the | |
| 145 | // page in memory between navigations. | |
| 290ea77 | 146 | app.use("*", async (c, next) => { |
| 147 | await next(); | |
| 148 | const ct = c.res.headers.get("content-type") || ""; | |
| 149 | if (ct.startsWith("text/html")) { | |
| 36cc17a | 150 | c.header("cache-control", "private, no-cache, must-revalidate"); |
| 290ea77 | 151 | } |
| 152 | }); | |
| 3ef4c9d | 153 | // Rate-limit API + auth endpoints (generous default) |
| 0316dbb | 154 | app.use("/api/*", rateLimit(120, 60_000, "api")); |
| 155 | app.use("/login", rateLimit(20, 60_000, "login")); | |
| 156 | app.use("/register", rateLimit(10, 60_000, "register")); | |
| c63b860 | 157 | // BLOCK P1 — throttle forgot-password to deter enumeration + mail spam. |
| 158 | app.use("/forgot-password", rateLimit(5, 60_000, "forgot-password")); | |
| 79136bb | 159 | |
| 59b6fb2 | 160 | // CSRF protection — set token on all requests, validate on mutations |
| 161 | app.use("*", csrfToken); | |
| 162 | app.use("*", csrfProtect); | |
| 163 | ||
| 45e31d0 | 164 | // Rate limit auth routes |
| 165 | app.use("/login", authRateLimit); | |
| 166 | app.use("/register", authRateLimit); | |
| 167 | ||
| 59b6fb2 | 168 | // Rate limit git operations |
| 169 | app.use("/:owner/:repo.git/*", gitRateLimit); | |
| 170 | ||
| 171 | // Rate limit search | |
| 172 | app.use("/:owner/:repo/search", searchRateLimit); | |
| 173 | app.use("/explore", searchRateLimit); | |
| 79136bb | 174 | |
| 175 | // Git Smart HTTP protocol routes (must be before web routes) | |
| 176 | app.route("/", gitRoutes); | |
| 177 | ||
| 45e31d0 | 178 | // REST API v1 (legacy) |
| 79136bb | 179 | app.route("/", apiRoutes); |
| 180 | ||
| 52ad8b1 | 181 | // Block L3 — /demo + /api/v2/demo/* live demo endpoints. Mounted BEFORE |
| 182 | // apiV2Routes so the /api/v2/demo/* JSON endpoints win over the v2 base | |
| 183 | // router's catch-shape, and BEFORE adminRoutes so the live /demo page | |
| 184 | // wins over the legacy /demo redirect in src/routes/admin.tsx. | |
| 185 | app.route("/", demoRoutes); | |
| 186 | ||
| 0316dbb | 187 | // REST API v2 (basePath /api/v2) |
| 188 | app.route("/", apiV2Routes); | |
| 189 | ||
| ad6d4ad | 190 | // Inbound API hooks (GateTest callback + backup PAT-authed /api/v1/gate-runs) |
| 191 | app.route("/", hookRoutes); | |
| 21f8dbd | 192 | app.route("/api/events", eventsRoutes); |
| ad6d4ad | 193 | |
| 45e31d0 | 194 | // API documentation |
| 195 | app.route("/", apiDocsRoutes); | |
| 79136bb | 196 | |
| 197 | // Auth routes (register, login, logout) | |
| 198 | app.route("/", authRoutes); | |
| 199 | ||
| c63b860 | 200 | // BLOCK P1 — Password reset (forgot-password + reset-password) |
| 201 | app.route("/", passwordResetRoutes); | |
| 202 | ||
| 203 | // BLOCK P2 — Email verification (verify-email + resend) | |
| 204 | app.route("/", emailVerificationRoutes); | |
| 205 | ||
| 79136bb | 206 | // Settings routes (profile, SSH keys) |
| 207 | app.route("/", settingsRoutes); | |
| 208 | ||
| 7298a17 | 209 | // 2FA / TOTP settings (Block B4) |
| 210 | app.route("/", settings2faRoutes); | |
| 211 | ||
| 2df1f8c | 212 | // WebAuthn / passkey routes (Block B5) |
| 213 | app.route("/", passkeyRoutes); | |
| 214 | ||
| 058d752 | 215 | // OAuth 2.0 provider (Block B6) |
| 216 | app.route("/", oauthRoutes); | |
| 217 | app.route("/", developerAppsRoutes); | |
| 218 | ||
| 6fc53bd | 219 | // Theme toggle (dark/light cookie) |
| 220 | app.route("/", themeRoutes); | |
| 221 | ||
| 222 | // Audit log UI | |
| 223 | app.route("/", auditRoutes); | |
| 224 | ||
| 225 | // Reactions API (issues, PRs, comments) | |
| 226 | app.route("/", reactionRoutes); | |
| 227 | ||
| 24cf2ca | 228 | // Saved replies (per-user canned comment templates) |
| 229 | app.route("/", savedReplyRoutes); | |
| 230 | ||
| 231 | // Environments + deployment history UI | |
| 232 | app.route("/", deploymentRoutes); | |
| 233 | ||
| 6563f0a | 234 | // Organizations + teams (Block B1) |
| 235 | app.route("/", orgRoutes); | |
| 236 | ||
| c81ab7a | 237 | // API tokens |
| 238 | app.route("/", tokenRoutes); | |
| 239 | ||
| 59b6fb2 | 240 | // Notifications |
| 3ef4c9d | 241 | app.route("/", notificationRoutes); |
| 242 | ||
| 79136bb | 243 | // Repo settings (description, visibility, delete) |
| 244 | app.route("/", repoSettings); | |
| 245 | ||
| 23d1a81 | 246 | // Repo collaborators (add/list/remove) |
| 247 | app.route("/", collaboratorRoutes); | |
| 248 | ||
| 04f6b7f | 249 | // Team-based repo collaborators (invite a whole team) |
| 250 | app.route("/", teamCollaboratorRoutes); | |
| 251 | ||
| 252 | // Collaborator invite accept flow (token-based) | |
| 253 | app.route("/", invitesRoutes); | |
| 254 | ||
| 255 | // Real-time SSE endpoint (topic-based live updates) | |
| 256 | app.route("/", liveEventsRoutes); | |
| 257 | ||
| c81ab7a | 258 | // Webhooks management |
| 259 | app.route("/", webhookRoutes); | |
| 260 | ||
| 79136bb | 261 | // Compare view (branch diffs) |
| 262 | app.route("/", compareRoutes); | |
| 263 | ||
| 264 | // Issue tracker | |
| 265 | app.route("/", issueRoutes); | |
| 266 | ||
| 0074234 | 267 | // Pull requests |
| 268 | app.route("/", pullRoutes); | |
| 269 | ||
| c81ab7a | 270 | // Fork |
| 271 | app.route("/", forkRoutes); | |
| 272 | ||
| 0074234 | 273 | // Web file editor |
| 274 | app.route("/", editorRoutes); | |
| 275 | ||
| 43de941 | 276 | // Contributors |
| 277 | app.route("/", contributorRoutes); | |
| 278 | ||
| 699e5c7 | 279 | // Health liveness + metrics endpoints |
| 2c34075 | 280 | app.route("/", healthRoutes); |
| 281 | ||
| f295f78 | 282 | // Cross-product platform status (public, CORS-open — see docs/PLATFORM_STATUS.md) |
| 283 | app.route("/api/platform-status", platformStatus); | |
| 284 | ||
| 52ad8b1 | 285 | // Block L4 — Public stats counters (powers landing-page social proof) |
| 286 | app.route("/", publicStatsRoutes); | |
| 287 | ||
| 288 | // Block L3 — Live /demo page + /api/v2/demo/* endpoints | |
| 289 | app.route("/", demoRoutes); | |
| 290 | ||
| 2316be6 | 291 | // Public /status — human-readable platform health page |
| 292 | app.route("/", statusRoutes); | |
| 293 | ||
| 80bed05 | 294 | // /help — quickstart + API cheatsheet |
| 295 | app.route("/", helpRoutes); | |
| 296 | ||
| 5f2e749 | 297 | // L8 — public /pricing page (free-tier polish). Mounted BEFORE marketing |
| 298 | // so the new editorial pricing layout wins the route; the legacy marketing | |
| 299 | // pricing remains as a safety net but is shadowed at the router. | |
| 300 | app.route("/", pricingRoutes); | |
| 301 | ||
| b0148e9 | 302 | // /pricing, /features, /about — marketing surface |
| 303 | app.route("/", marketingRoutes); | |
| 304 | ||
| 5618f9a | 305 | // SEO: robots.txt + sitemap.xml |
| 306 | app.route("/", seoRoutes); | |
| 307 | ||
| 05cdb85 | 308 | // /api/version — live build SHA + uptime; client poller uses this to |
| 309 | // surface 'New version available — reload' banners on deploy. | |
| 310 | app.route("/", versionRoutes); | |
| 311 | ||
| 699e5c7 | 312 | // Health dashboard (per-repo health page) |
| 313 | app.route("/", healthDashboardRoutes); | |
| 314 | ||
| 16b325c | 315 | // Insights (time-travel, dependencies, rollback) |
| 316 | app.route("/", insightRoutes); | |
| 317 | ||
| f1ab587 | 318 | // Command center dashboard |
| 319 | app.route("/", dashboardRoutes); | |
| 320 | ||
| 36b4cbd | 321 | // Legal pages (terms, privacy, AUP) |
| 322 | app.route("/", legalRoutes); | |
| 323 | ||
| bdbd0de | 324 | // GitHub import / migration |
| 325 | app.route("/", importRoutes); | |
| 14c3cc8 | 326 | app.route("/", importBulkRoutes); |
| 327 | app.route("/", migrationRoutes); | |
| 328 | ||
| 329 | // Spec-to-PR (experimental AI-generated draft PRs) | |
| 330 | app.route("/", specsRoutes); | |
| bdbd0de | 331 | |
| c81ab7a | 332 | // Explore page |
| 333 | app.route("/", exploreRoutes); | |
| 334 | ||
| 59b6fb2 | 335 | // Onboarding |
| 336 | app.route("/", onboardingRoutes); | |
| 337 | ||
| 0316dbb | 338 | // Admin + feature routes |
| 339 | app.route("/", adminRoutes); | |
| f764c07 | 340 | app.route("/", adminDeploysRoutes); |
| 341 | app.route("/", adminDeploysPageRoutes); | |
| 0316dbb | 342 | app.route("/", advisoriesRoutes); |
| 343 | app.route("/", aiChangelogRoutes); | |
| 344 | app.route("/", aiExplainRoutes); | |
| 345 | app.route("/", aiTestsRoutes); | |
| 346 | app.route("/", askRoutes); | |
| 347 | app.route("/", billingRoutes); | |
| 6778ad2 | 348 | app.route("/", stripeWebhookRoutes); |
| 0316dbb | 349 | app.route("/", codeScanningRoutes); |
| 350 | app.route("/", commitStatusesRoutes); | |
| 351 | app.route("/", copilotRoutes); | |
| 352 | app.route("/", depUpdaterRoutes); | |
| 353 | app.route("/", depsRoutes); | |
| 354 | app.route("/", discussionsRoutes); | |
| 355 | app.route("/", environmentsRoutes); | |
| 356 | app.route("/", followsRoutes); | |
| 357 | app.route("/", gatesRoutes); | |
| 358 | app.route("/", gistsRoutes); | |
| 359 | app.route("/", graphqlRoutes); | |
| 2c2163e | 360 | app.route("/", mcpRoutes); |
| 0316dbb | 361 | app.route("/", marketplaceRoutes); |
| 362 | app.route("/", mergeQueueRoutes); | |
| 363 | app.route("/", mirrorsRoutes); | |
| 364 | app.route("/", orgInsightsRoutes); | |
| 365 | app.route("/", packagesRoutes); | |
| 366 | app.route("/", packagesApiRoutes); | |
| 367 | app.route("/", pagesRoutes); | |
| 368 | app.route("/", projectsRoutes); | |
| 369 | app.route("/", protectedTagsRoutes); | |
| 370 | app.route("/", pwaRoutes); | |
| 46d6165 | 371 | app.route("/", installRoutes); |
| 0316dbb | 372 | app.route("/", releasesRoutes); |
| 373 | app.route("/", requiredChecksRoutes); | |
| 374 | app.route("/", rulesetsRoutes); | |
| 375 | app.route("/", searchRoutes); | |
| 376 | app.route("/", semanticSearchRoutes); | |
| 377 | app.route("/", signingKeysRoutes); | |
| 378 | app.route("/", sponsorsRoutes); | |
| 379 | app.route("/", ssoRoutes); | |
| 46d6165 | 380 | app.route("/", githubOauthRoutes); |
| 0316dbb | 381 | app.route("/", symbolsRoutes); |
| 382 | app.route("/", templatesRoutes); | |
| 383 | app.route("/", trafficRoutes); | |
| 384 | app.route("/", wikisRoutes); | |
| 385 | app.route("/", workflowsRoutes); | |
| 5ff9cc2 | 386 | app.route("/", workflowArtifactsRoutes); |
| 387 | app.route("/", workflowSecretsRoutes); | |
| 46d6165 | 388 | app.route("/", sleepModeRoutes); |
| 52ad8b1 | 389 | app.route("/", vsGithubRoutes); |
| 0316dbb | 390 | |
| 79136bb | 391 | // Web UI (catch-all, must be last) |
| 392 | app.route("/", webRoutes); | |
| 393 | ||
| c63b860 | 394 | // Global 404 — BLOCK O2 routes the shared `NotFoundPage` view so |
| 395 | // the markup stays consistent with /500 and the admin /403 page. | |
| 79136bb | 396 | app.notFound((c) => { |
| 36cc17a | 397 | const user = c.get("user") ?? null; |
| 79136bb | 398 | return c.html( |
| c63b860 | 399 | <NotFoundPage user={user} method={c.req.method} path={c.req.path} />, |
| 79136bb | 400 | 404 |
| 401 | ); | |
| 402 | }); | |
| 403 | ||
| c63b860 | 404 | // Global error handler — BLOCK O2 uses the shared `ServerErrorPage` |
| 405 | // view. Trace block only shown outside production. | |
| 79136bb | 406 | app.onError((err, c) => { |
| 80bed05 | 407 | reportError(err, { |
| 408 | requestId: c.get("requestId"), | |
| 409 | path: c.req.path, | |
| 410 | method: c.req.method, | |
| 411 | }); | |
| c63b860 | 412 | // Prefer the inbound `x-request-id` header (LB-supplied) and fall |
| 413 | // back to the context value set by request-context middleware. | |
| 414 | const requestId = | |
| 415 | c.req.header("x-request-id") || | |
| 416 | ((c.get("requestId" as never) as string | undefined) ?? undefined); | |
| 36cc17a | 417 | const user = c.get("user") ?? null; |
| c63b860 | 418 | const trace = |
| 419 | process.env.NODE_ENV !== "production" && err && err.message | |
| 420 | ? err.message | |
| 421 | : undefined; | |
| 79136bb | 422 | return c.html( |
| c63b860 | 423 | <ServerErrorPage user={user} requestId={requestId} trace={trace} />, |
| 79136bb | 424 | 500 |
| 425 | ); | |
| 426 | }); | |
| 427 | ||
| 428 | export default app; |