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#
getRootgetRoot<T extends Discovery = Discovery>(): T
#
return root discovery instance
#
getParentgetParent<T extends Discovery = Discovery>(): T
#
return parent discovery instance
#
exportedget exported(): IExported[]
#
getter return discovery exported files
#
filterByTypefilterByType(fn: Class): IExported[]
#
return filter exported by given fn type
#
findByTypefindByType(fn: Class): IExported
#
return first match by class type
#
findReflectDatafindReflectData<T>(symbol: Symbol | string): IExported & { metaData: T }
#
find the first class matched given symbol metadata
#
findAllReflectDatafindAllReflectData<T>(symbol: Symbol | string): (IExported & { metaData: T })[]
#
return all class matched given symbol metadata
#
setReflectMetadatasetReflectMetadata(key: string | Symbol, value: any, target: any, propertyKey?: string)
#
set value by given symbol on target class.
- Also, available as static method.
#
getReflectMetadatagetReflectMetadata<T>(symbol: Symbol | string, klass: any, propertyName?: string, defaultValue?: T): T
#
get value by given symbol on target class.
- Also, available as static method.
#
decorateReflectMetadatadecorateReflectMetadata(key: string | Symbol, value: any)
#
create decorator function.
- Also, available as static method.
#
getClassDefinitiongetClassDefinition(fn: Function): Define
#
return inject
class definition if exists.
- Also, available as static method.
#
hasClassDefinitionhasClassDefinition(fn: Function): boolean
#
return true if given class has inject
class definition.
- Also, available as static method.
#
getClassIdgetClassId(fn: Function): string
#
return class id from inject
class definition.
- Also, available as static method.
#
getClassNamegetClassName(fn: Function): string
#
return class name.
- Also, available as static method.
#
getControllerNamegetControllerName(controller: string | typeof Controller | typeof StaticController)
#
return class controller name.
- Also, available as static method.
- Only available on root Discovery
@appolo/core
.
#
decorateRequestdecorateRequest(name: string, fn: Function)
#
extend @appolo/agent
request prototype
- Also, available as static method.
- Only available on root Discovery
@appolo/core
.
#
decorateResponsedecorateResponse(name: string, fn: Function)
#
extend @appolo/agent
response prototype
- Also, available as static method.
- Only available on root Discovery
@appolo/core
.
#
getRoutegetRoute<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
.
#
createRoutecreateRoute<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
.
#
isControllerisController(fn: any): boolean
#
return true if given class is a controller.
- Also, available as static method.
- Only available on root Discovery
@appolo/core
.