Skip to content

ControllerMetadata

reference
1 min readUpdated

Kind: Interface

Source: packages/common/interfaces/controllers/controller-metadata.interface.ts

Part of: Common

ControllerMetadata defines the metadata associated with a controller, currently consisting of its route path. Framework decorators or registration logic can use this interface to store and retrieve the base URL segment for controller instances.

Properties

PropertyType
pathstring

Diagram

mermaid
graph LR
  Controller["Controller Class"] --> Metadata["ControllerMetadata"]
  Metadata --> Path["path: string"]
  Path --> Router["Route Registration"]

Usage

ts
import type { ControllerMetadata } from './controller-metadata.interface';

const metadata: ControllerMetadata = {
  path: '/users',
};

function registerController(controller: ControllerMetadata) {
  console.log(`Registering controller at ${controller.path}`);
}

registerController(metadata);

AI Coding Instructions

  • Keep path as a string representing the controller's base route path.
  • Use this interface when passing or storing controller-level routing metadata.
  • Normalize route paths consistently in the router or decorator layer (for example, handling leading slashes).
  • Avoid adding request-specific or method-specific metadata here; keep those concerns in separate interfaces.

Was this page helpful?

Download as PDF
ControllerMetadata — NestJS head-to-head