Skip to content

Services

Big Mogician edited this page Dec 9, 2018 · 3 revisions

内置服务

  1. Context
// 基础上下文服务
class Context<T extends IContext> = {}> {
  readonly ctx: T;
}
  1. Configs
// 全局配置容器服务
class Configs implements ReadonlyConfigs {
  // 获取配置
  get<T>(token: ConfigToken<T>): T;
}
  1. InjectService
// 依赖注入服务
class InjectService {
  // 当前范围ID
  readonly scopeId: ScopeID;
  // 获取实例
  get<T>(token: InjectDIToken<T>): T;
}
  1. AstroboyContext
// astroboy 基础上下文
class AstroboyContext<T = IContext, A = Koa.Application, C = any> {

  /** BaseClass.ctx */
  readonly ctx: T;
  /** BaseClass.app */
  readonly app: A;
  /** BaseClass.config */
  readonly config: C;

  getConfig(...args: any[]): any;

  getServiceClass(...args: any[]): any;

  getService(...args: any[]): any;

  callService(...args: any[]): any;

  invokeServiceMethod(...args: any[]): any;

  getLib(...args: any[]): any;

}
Clone this wiki locally