Skip to main content

OpraHttpNestjsAdapter

HttpAdapter subclass that integrates OPRA's HTTP processing into NestJS. At module initialisation it generates NestJS controller classes from OPRA HttpController definitions and registers them with the NestJS IoC container.

import { OpraHttpNestjsAdapter } from '@opra/nestjs-http';

Extends: HttpAdapter (@opra/http)

You do not instantiate this class directly — OpraHttpModule creates and registers it automatically.


Properties​

PropertyTypeDescription
platform'nestjs'Identifies the platform.
nestControllersType[]The generated NestJS controller classes registered for this adapter.

How it works​

When OpraHttpModule initialises, OpraHttpNestjsAdapter:

  1. Walks every HttpController in the ApiDocument
  2. Generates a NestJS @Controller class for each one, with @Get, @Post, … decorators on each operation method
  3. Copies OPRA metadata and NestJS guards/interceptors/filters from the original controller class onto the generated class (via OpraNestUtils.copyDecoratorMetadata)
  4. Registers the generated controllers with NestJS
  5. Exposes GET /$schema for the API document (public by default if schemaIsPublic is set)

Each request flows through NestJS routing into the adapter's handleRawRequest → OPRA context creation → handler dispatch → response serialisation pipeline, identical to the standalone ExpressAdapter pipeline.


See also​