Skip to content

code_route

code_route resolves an HTTP route path to the controller method that handles it. It parses framework decorators (NestJS, Express, Fastify) and returns the handler’s file and line number.

code_route(route="/api/users")
code_route(route="/api/orders", method="POST")
code_route()
ParameterTypeDefaultDescription
routestringURL path to find a handler for
method"GET" | "POST" | "PUT" | "DELETE" | "PATCH"HTTP method filter
GET /api/users → UserController.list
src/controllers/user.ts:24
POST /api/users → UserController.create
src/controllers/user.ts:51

Calling code_route() with no arguments lists all registered routes.

  • Trace a failing API request to its handler
  • Find which function to read when debugging a specific endpoint
  • Get a full route inventory for documentation or security review

For a full chain from route through service to database, use code_route_trace:

code_route_trace(route="/api/users", method="POST")
→ Router → UserController.create → UserService.create → db.insert