@micro.ts/core
Version:
Microservice framework with Typescript
45 lines (44 loc) • 1.43 kB
TypeScript
import 'reflect-metadata';
import { Class } from '../server/types';
import { ContainerModule } from './ContainerModule';
import { ResolverFunction, DiRegistry } from './DiRegistry';
import { ServiceOptions } from './types';
import { ServiceScope } from './types/DiOptionsTypes';
export declare class BaseContainer {
private registry;
constructor(registry?: DiRegistry);
private root;
/**
* Bind a Class constructor to the container
* @param type
* @param options
*/
registerService(type: any, options: ServiceOptions): void;
newModule(): ContainerModule;
/**
* Bind a resolver function to a specific key
* @param key
* @param resolver
* @param scope
*/
bindResolver(key: any, resolver: ResolverFunction<any>, scope?: ServiceScope): void;
/**
* Check if a resolver with the given key is registered in the registry
* @param key
*/
hasResolver(key: any): boolean;
/**
* Explicitly set a value to the container in global scope
* @param key
* @param value
*/
set(key: any, value: any): void;
/**
* Get the instance from the container,
* if it does not exist, create a new instance
* @param key Key or Class constructor of the instance
*/
get<T = any>(key: Class<T> | string | any): T;
}
export declare const Container: BaseContainer;
export declare function printContainer(): void;