@opra/nestjs
Version:
Opra NestJS module
53 lines (52 loc) • 2.09 kB
TypeScript
import { type Type } from '@nestjs/common';
import { ModulesContainer } from '@nestjs/core';
import { ExternalContextCreator } from '@nestjs/core/helpers/external-context-creator.js';
import type { InstanceWrapper } from '@nestjs/core/injector/instance-wrapper.js';
import type { Module } from '@nestjs/core/injector/module.js';
/**
* Factory class that wraps Opra controllers into NestJS controllers.
*/
export declare class RpcControllerFactory {
private readonly modulesContainer;
private readonly externalContextCreator;
protected _metadataKey: symbol;
private _coreModuleRef?;
private readonly paramsFactory;
private readonly injector;
constructor(modulesContainer: ModulesContainer, externalContextCreator: ExternalContextCreator);
/**
* Wraps and returns the controllers as NestJS compatible classes.
*
* @returns An array of NestJS compatible controller classes.
*/
wrapControllers(): Type[];
/**
* Creates a context callback for a controller method.
*
* @param instance - The controller instance.
* @param wrapper - The instance wrapper.
* @param moduleRef - The module reference.
* @param methodName - The name of the method to wrap.
* @param isRequestScoped - Whether the controller is request-scoped.
* @param contextType - The NestJS context type.
* @param options - Optional external context options.
* @returns A callback function that handles the execution context.
*/
private _createContextCallback;
/**
* Registers a context provider for the given request and context ID.
*
* @param request - The request object (Opra execution context).
* @param contextId - The NestJS context ID.
*/
private registerContextProvider;
/**
* Explores and returns all Opra controllers within the NestJS application.
*
* @returns An array of objects containing the module and instance wrapper for each controller.
*/
exploreControllers(): {
module: Module;
wrapper: InstanceWrapper;
}[];
}