typenexus
Version:
TypeNexus is a good tool for API encapsulation and management. It provides a clean and lightweight way to package TypeORM functionality, helping you build applications faster while reducing template code redundancy and type conversion work.
69 lines (68 loc) • 2.27 kB
TypeScript
import { ControllerMetadataArgs } from './args/ControllerMetadataArgs.js';
import { ResponseHandlerMetadata } from './ResponseHandleMetadata.js';
import { ActionMetadata } from './ActionMetadata.js';
import { UseMetadata } from './UseMetadata.js';
import { Action } from '../Action.js';
/**
* Container options.
*/
export interface UseContainerOptions {
/**
* If set to true, then default container will be used in the case if given container haven't returned anything.
*/
fallback?: boolean;
/**
* If set to true, then default container will be used in the case if given container thrown an exception.
*/
fallbackOnErrors?: boolean;
}
export type ClassConstructor<T, K = unknown> = {
new (...args: K[]): T;
};
/**
* Gets the IOC container used by this library.
* @param someClass A class constructor to resolve
* @param action The request/response context that `someClass` is being resolved for
*/
export declare function getFromContainer<T, K = unknown>(someClass: ClassConstructor<T, K> | Function, action?: Action, paramsConstructor?: any[]): T;
/**
* Controller metadata.
*/
export declare class ControllerMetadata {
actions: ActionMetadata[];
/**
* Indicates object which is used by this controller.
*/
target: Function;
/**
* Base route for all actions registered in this controller.
*/
route: string;
/**
* Controller type. Can be default or json-typed. Json-typed controllers operate with json requests and responses.
*/
type: 'default' | 'json';
/**
* Indicates if this action uses Authorized decorator.
*/
isAuthorizedUsed: boolean;
/**
* Middleware "use"-s applied to a whole controller.
*/
uses: UseMetadata[];
/**
* Roles set by @Authorized decorator.
*/
authorizedRoles: any[];
constructor(args: ControllerMetadataArgs);
/**
* Gets instance of the controller.
* @param action Details around the request session
*/
getInstance(action: Action, paramsConstructor?: any[]): any;
/**
* Builds everything controller metadata needs.
* Controller metadata should be used only after its build.
*/
build(responseHandlers: ResponseHandlerMetadata[]): void;
}