Skip to main content
The @Override() decorator allows you to replace or extend the default behavior of generated CRUD routes with your own custom logic.

Basic usage

Use the @Override() decorator on a controller method to replace a generated route:

The @Override() decorator

BaseRouteName
The name of the route to override. If omitted, the method name (with ‘Base’ suffix) is used.

Available route names

  • getManyBase
  • getOneBase
  • createOneBase
  • createManyBase
  • updateOneBase
  • replaceOneBase
  • deleteOneBase
  • recoverOneBase

Calling the base implementation

To call the original generated route handler, use this.base:
You must implement the base getter that returns this to access base route implementations.

Using @ParsedRequest()

The @ParsedRequest() decorator provides a CrudRequest object with parsed query parameters:

Common override patterns

Add logging

Add authorization

Modify query parameters

Transform response

Custom validation

Complete custom implementation

You can completely replace the base implementation:

Override without specifying name

When the method name matches the route name (with ‘Base’ suffix), you can omit the decorator parameter:

Adding route decorators

You can add any NestJS decorators to override methods:

Working with bulk operations

Accessing request and response

You can inject standard NestJS decorators:
When using @Res(), make sure to include { passthrough: true } to allow NestJS to handle the response serialization.

Soft delete recovery

Best practices

Use proper TypeScript types for better IDE support and type safety:
Override methods should have a single responsibility. If you need complex logic, extract it to service methods:
Add JSDoc comments to explain why you’re overriding:
Override methods should be covered by unit and integration tests: