UNPKG

1.16 kBTypeScriptView Raw
1import { Action } from './Action';
2/**
3 * Container options.
4 */
5export interface UseContainerOptions {
6 /**
7 * If set to true, then default container will be used in the case if given container haven't returned anything.
8 */
9 fallback?: boolean;
10 /**
11 * If set to true, then default container will be used in the case if given container thrown an exception.
12 */
13 fallbackOnErrors?: boolean;
14}
15export declare type ClassConstructor<T> = {
16 new (...args: any[]): T;
17};
18/**
19 * Allows routing controllers to resolve objects using your IoC container
20 */
21export interface IocAdapter {
22 /**
23 * Return
24 */
25 get<T>(someClass: ClassConstructor<T>, action?: Action): T;
26}
27/**
28 * Sets container to be used by this library.
29 */
30export declare function useContainer(iocAdapter: IocAdapter, options?: UseContainerOptions): void;
31/**
32 * Gets the IOC container used by this library.
33 * @param someClass A class constructor to resolve
34 * @param action The request/response context that `someClass` is being resolved for
35 */
36export declare function getFromContainer<T>(someClass: ClassConstructor<T> | Function, action?: Action): T;