Feature: HANDLES edges and per-registration data for generic router.add(method, path, handler) registrations (TypeScript)

Offen
#3,089 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
48/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv
Tech-Stack
typescript

Rechercherichtung

Start by tracing TypeScript route extraction and the framework-specific registration patterns that create Route nodes and HANDLES edges; the issue does not name source files or tests. Reproduce the reported generic router.add(method, path, handler) case and inspect how call-site arguments are stored on CALLS edges. Done means each method and path produces a route with its registration location and a HANDLES edge to the relevant handler target.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

enhancement parsing/quality

Feature request: HANDLES edges for generic router.add(method, path, handler) registrations

Version: codebase-memory-mcp v0.12.1 (linux-amd64-portable), TypeScript project.

What happens

A hand-written router registers routes with a plain method call. The indexer creates the Route nodes
(path parameters normalised to {}), but no HANDLES edge from the route to the handler function, and the
Route node carries no method, file or line. Only framework-specific registrations (Express, Fastify, ...)
get HANDLES.

Minimal example

// router.ts
export class Router {
  add(method: string, path: string, handler: (req: Request, ctx: { params: Record<string, string> }) => Promise<Response>) { /* ... */ }
}

// routes.ts
import { Router } from './router'
export async function replaceCredential(providerId: string, req: Request): Promise<Response> { /* ... */ }
export async function clearCredential(providerId: string, req: Request): Promise<Response> { /* ... */ }

export function registerRoutes(router: Router) {
  router.add('PUT', '/v1/connections/:providerId/credential', async (req, ctx) => {
    if (!authorize(req)) return unauthorized()
    return replaceCredential(ctx.params.providerId, req)
  })
  router.add('DELETE', '/v1/connections/:providerId/credential', (req, ctx) => clearCredential(ctx.params.providerId, req))
}

Observed after index_repository(mode=full):

  • MATCH (r:Route) RETURN r.name, r.method → /v1/connections/{}/credential, method "" (one node for PUT and DELETE)
  • MATCH (r:Route)-[:HANDLES]->(f) RETURN f.name → 0 rows
  • MATCH (f)-[r:CALLS]->(g) WHERE f.name='registerRoutes' AND g.name='add' RETURN r.args, r.line → one edge
    (one CALLS edge per caller/callee pair), carrying the args of a single registration although the function
    registers two routes (in the real project: 81 registrations in one function, one edge).

Expected

  • Route nodes per (method, path) with method, file_path, start_line set.
  • HANDLES edge from the route to the call target(s) in return position of the inline handler (here
    replaceCredential / clearCredential), or to the referenced function when the handler argument is an
    identifier.
  • Optionally the guard calls inside if conditions that lead to an early return (authorize) as a separate
    edge/property, since they are the authorisation preconditions of the route.

Suggestion

A generic registration pattern in service_patterns keyed by callee name and argument positions
(callee: "router.add", method: 0, path: 1, handler: 2), configurable per project, would cover hand-written
routers without framework detection. The call-site arguments are already captured on the CALLS edge, so the data
exists; only the per-call-site linking is missing.

Vorherrschende Sprache
C
Sterne
45.8k
Forks
3.8k
Ø Merge
2 T. 18 Std.
Gemergte PRs (30 T.)
108

Entwicklungsumgebung

Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus DeusData/codebase-memory-mcp

Alle Issues in DeusData/codebase-memory-mcp

Ähnliche Issues

Weitere Issues zu C

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.