Skip to content

[NestJS] Add controller route resolver #98

Description

@Yashasvi2229

Target branch: code-graph-preview

Dependency

The TypeScript extractor is already available on code-graph-preview. No language-extractor issue blocks this resolver.

Goal

Add a bounded NestJS resolver that connects decorator-defined controller routes to their handler methods. The first version should focus only on HTTP controller routes that can be identified confidently from source.

Scope

  • Detect NestJS through @nestjs/common in dependencies or dev dependencies.
  • Recognize classes decorated with @Controller().
  • Recognize methods decorated with @Get, @Post, @Put, @Patch, @Delete, @Options, @Head, or @All.
  • Combine the controller prefix and method path into a normalized route name such as GET /users/:id.
  • Emit a route node and a function_ref reference to the controller method.
  • Resolve an unambiguous route reference to the matching method node, preferring the same file/class context.
  • Preserve unresolved or ambiguous references rather than guessing.

Required changes

  • Add src/graph/resolution/frameworks/nestjs.ts implementing FrameworkResolver.
  • Register and export it from src/graph/resolution/frameworks/index.ts.
  • Add a minimal NestJS controller fixture.
  • Add focused detection, extraction, resolution, and ambiguity tests.

Acceptance criteria

  • Positive and negative NestJS detection are tested.
  • Controller and method paths are normalized without losing dynamic parameter text.
  • Tests cover at least two HTTP methods, a controller prefix, an empty method path, and a parameterized path.
  • Route nodes use stable ids and TypeScript-family language ids.
  • Same-file methods resolve with confidence only when unambiguous.
  • Duplicate handler names or missing methods remain unresolved.
  • The resolver is additive and does not change the frozen interface.
  • npm run typecheck, npm test, and npm run build pass.

Out of scope

  • Dependency-injection graph edges.
  • Guards, pipes, interceptors, middleware, gateways, GraphQL, or microservices.
  • Runtime decorator evaluation.
  • Changes to the TypeScript extractor or graph core.

Contributor references

Contributor workflow

git switch code-graph-preview
git pull
git switch -c feat/nestjs-route-resolver

Open the pull request with base branch code-graph-preview.

Metadata

Metadata

Assignees

Labels

code-graphWork related to the AST and Tree-sitter code graphdeveloper-previewPart of an unreleased developer previewhelp wantedExtra attention is needed

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions