Skip to content

zhang740/egg-typed

Repository files navigation

egg-typed

NPM version build status Test coverage David deps Known Vulnerabilities

An onther style (like C#/java) of egg enterprise app framework.

Quick overview

路由

egg-controller

export class HomeController extends Controller {
  // 如果不需要访问ctx,则不需要继承
  @route("/api/xxx", { name: "获取XXX数据" })
  async getXXX(size: number, page: number) {
    return "homeIndex";
  }
}

依赖注入

egg-aop

export class TestService extends Service {
  get(id: string | number) {
    return {
      id,
      name: this.app.config.test + "_" + id
    };
  }
}

export class HomeController extends Controller {
  @lazyInject()
  testService: TestService;

  @route("/api/xxx", { name: "获取XXX数据" })
  async getXXX(id: string) {
    return this.testService.get(id);
  }
}

ORM

调用链跟踪

场景测试

使用 & 配置方法

  1. use egg-init to initialize a project.

  2. config project.json add:

  "egg": {
    "framework": "egg-typed"
  },
  1. An example of tsconfig.json:
{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "moduleResolution": "node",
    "noImplicitAny": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "preserveConstEnums": true,
    "declaration": true,
    "sourceMap": true,
    "rootDir": "src",
    "outDir": "app",
    "pretty": true
  }
}

Questions & Suggestions

Please open an issue here.