Discovery
Discovery class handles exported modules files and custom decorators. Discovery can be injected or accessed from app context or used as static class.
Usage#
getRoot#
getRoot<T extends Discovery = Discovery>(): T#
return root discovery instance
getParent#
getParent<T extends Discovery = Discovery>(): T#
return parent discovery instance
exported#
get exported(): IExported[]#
getter return discovery exported files
filterByType#
filterByType(fn: Class): IExported[]#
return filter exported by given fn type
findByType#
findByType(fn: Class): IExported#
return first match by class type
findReflectData#
findReflectData<T>(symbol: Symbol | string): IExported & { metaData: T }#
find the first class matched given symbol metadata
findAllReflectData#
findAllReflectData<T>(symbol: Symbol | string): (IExported & { metaData: T })[]#
return all class matched given symbol metadata
setReflectMetadata#
setReflectMetadata(key: string | Symbol, value: any, target: any, propertyKey?: string)#
set value by given symbol on target class.
- Also, available as static method.
getReflectMetadata#
getReflectMetadata<T>(symbol: Symbol | string, klass: any, propertyName?: string, defaultValue?: T): T#
get value by given symbol on target class.
- Also, available as static method.
decorateReflectMetadata#
decorateReflectMetadata(key: string | Symbol, value: any)#
create decorator function.
- Also, available as static method.
getClassDefinition#
getClassDefinition(fn: Function): Define#
return inject class definition if exists.
- Also, available as static method.
hasClassDefinition#
hasClassDefinition(fn: Function): boolean#
return true if given class has inject class definition.
- Also, available as static method.
getClassId#
getClassId(fn: Function): string#
return class id from inject class definition.
- Also, available as static method.
getClassName#
getClassName(fn: Function): string#
return class name.
- Also, available as static method.
getControllerName#
getControllerName(controller: string | typeof Controller | typeof StaticController)#
return class controller name.
- Also, available as static method.
- Only available on root Discovery @appolo/core.
decorateRequest#
decorateRequest(name: string, fn: Function)#
extend @appolo/agent request prototype
- Also, available as static method.
- Only available on root Discovery @appolo/core.
decorateResponse#
decorateResponse(name: string, fn: Function)#
extend @appolo/agent response prototype
- Also, available as static method.
- Only available on root Discovery @appolo/core.
getRoute#
getRoute<T extends IController>(fn: any, action: ((c: T) => Function) | string): Route<T>#
return controller route definition
- Also, available as static method.
- Only available on root Discovery @appolo/core.
createRoute#
createRoute<T extends IController>(fn: any, action: ((c: T) => Function) | string): Route<T>#
create controller route definition.
- Also, available as static method.
- Only available on root Discovery @appolo/core.
isController#
isController(fn: any): boolean#
return true if given class is a controller.
- Also, available as static method.
- Only available on root Discovery @appolo/core.