# RouteInfo

**Kind:** Interface

**Source:** [`packages/common/interfaces/middleware/middleware-configuration.interface.ts`](https://github.com/nestjs/nest/blob/master/packages/common/interfaces/middleware/middleware-configuration.interface.ts#L5)

**Part of:** [Common](subsystem-packages-common)

`RouteInfo` describes a single route targeted by middleware configuration. It combines the route path, HTTP request method, and API version so middleware can be applied to the correct endpoint variant.

## Properties

| Property | Type |
|---|---|
| `path` | `string` |
| `method` | `RequestMethod` |
| `version` | `VersionValue` |

## Diagram

```mermaid
graph LR
  Middleware[Middleware Configuration] --> RouteInfo
  RouteInfo --> Path[path: string]
  RouteInfo --> Method[method: RequestMethod]
  RouteInfo --> Version[version: VersionValue]
  RouteInfo --> TargetRoute[Versioned HTTP Route]
```

## Usage

```ts
import { RequestMethod } from '@nestjs/common';
import type { RouteInfo } from './middleware-configuration.interface';

const protectedRoute: RouteInfo = {
  path: 'users/:id',
  method: RequestMethod.GET,
  version: '1',
};

// Example: register middleware for a specific versioned endpoint.
consumer
  .apply(AuthMiddleware)
  .forRoutes(protectedRoute);
```

## AI Coding Instructions

- Provide all three fields when creating a `RouteInfo`: `path`, `method`, and `version`.
- Use `RequestMethod` enum values instead of raw HTTP method strings such as `'GET'`.
- Keep `path` consistent with the application's route definitions, including parameter segments like `:id`.
- Set `version` to the same `VersionValue` used by the controller or route being targeted.
- Use `RouteInfo` when middleware must apply to a specific method and API version rather than an entire controller.

## Used by

5 references from 5 files. Each is a place in this repository where the symbol is actually used — go read one rather than trusting an example.

### Imported by (5)

- `MiddlewareBuilder` — `packages/core/middleware/builder.ts`:17
- `handler` — `packages/core/middleware/middleware-module.ts`:287
- `RouteInfoPathExtractor` — `packages/core/middleware/route-info-path-extractor.ts`:16
- `modulesContainer` — `packages/core/middleware/routes-mapper.ts`:148
- `anonymousMiddleware` — `packages/core/middleware/utils.ts`:77
