Routes and tags

Centralized route configuration with RouterConfigBase.

Routes and OpenAPI tags are centralized in configuration classes, avoiding duplicated strings across controllers.

typescript
export abstract class RouterConfigBase {
  protected constructor(
    private readonly _tag: string,
    private readonly _group: string,
  ) {}

  get group() {
    return this._group;
  }

  get tag() {
    return this._tag;
  }
}
  • group — route prefix passed to NestJS @Controller() (e.g. /person).
  • tag — grouping in Swagger/Scalar (e.g. Person).
typescript
class PersonRouterConfig extends RouterConfigBase {
  constructor() {
    super('Person', '/person');
  }
}

export const PERSON_ROUTER_CONFIG = new PersonRouterConfig();

All Person controllers share the same configuration:

typescript
@Controller(PERSON_ROUTER_CONFIG)
export class CreatePersonController implements IController<...> { ... }

@Controller(PERSON_ROUTER_CONFIG)
export class ReadManyPersonController implements IController<...> { ... }

This groups endpoints under /person and the Person tag in interactive documentation.

Method Route Controller
POST /person CreatePersonController
GET /person ReadManyPersonController
GET /person/:id ReadPersonController
PUT /person UpdatePersonController
DELETE /person/:id DeletePersonController
  1. Create src/host/controllers/<resource>/router.config.ts.
  2. Extend RouterConfigBase with the desired tag and prefix.
  3. Export a constant instance (e.g. PRODUCT_ROUTER_CONFIG).
  4. Use @Controller(PRODUCT_ROUTER_CONFIG) on all resource controllers.

Koala Nest

A facilitator for building NestJS APIs with DDD architecture. Code copied into your repository — readable, adaptable, and under your control.

Creator

igordrangel.com.br

Design, back-end, and product strategy.

Quick Commands

Global CLI and scripts in the generated project

  • bun install -g @koalarx/nest
  • kl-nest new
  • kl-nest add cache
  • bun run migration:run # CRUD template
  • kl-nest --help
© 2026 Koala NestBuilt for NestJS developers and AI-assisted workflows.