Skip to content

Hono framework sub-router routes not detected (~82% miss rate) #307

@xrntkk

Description

@xrntkk

Summary

When indexing a Hono-based monorepo project, CodeGraph's route detection only captures ~18% of actual HTTP endpoints. The missed routes are defined in sub-router files that are mounted via app.route("/prefix", subRouter) in the main entry file.

Environment

  • CodeGraph version: v0.9.2
  • Framework: Hono (API nearly identical to Express)
  • Project: TypeScript monorepo (pnpm workspace), ~1,200+ indexed files
  • Also includes Python/Flask routes (completely missed)

Expected Behavior

All HTTP route handlers defined on Hono router instances should be indexed as route kind nodes, regardless of the variable name or file location. Since CodeGraph documents Express app.get(...) / router.post(...) support, the nearly identical Hono syntax should work as well.

Actual Behavior

Only routes directly defined on the main app variable or inside certain factory functions are indexed. Routes in sub-router files (the vast majority) are completely missed.

Minimal Reproduction

// src/server.ts (entry file)
import { Hono } from "hono";
import userRoutes from "./routes/userRoutes";
import postRoutes from "./routes/postRoutes";

const app = new Hono();

// ✅ This mount point IS indexed as a route node
app.route("/api/users", userRoutes);
app.route("/api/posts", postRoutes);

// ✅ This direct route IS indexed
app.get("/health", (c) => c.json({ ok: true }));
// src/routes/userRoutes.ts (sub-router)
import { Hono } from "hono";

const router = new Hono();

// ❌ NONE of these are indexed
router.get("/", listUsers);
router.get("/:id", getUser);
router.post("/", createUser);
router.put("/:id", updateUser);
router.delete("/:id", deleteUser);

export default router;
// src/routes/postRoutes.ts (sub-router)
import { Hono } from "hono";

const posts = new Hono();

// ❌ NONE of these are indexed either
posts.get("/", listPosts);
posts.get("/:id", getPost);
posts.post("/", createPost);

export default posts;

After codegraph index, querying codegraph_search({ kind: "route" }) returns:

  • USE /api/users (mount point only)
  • USE /api/posts (mount point only)
  • GET /health

But misses all 8 sub-router endpoints.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions