code: function restApi(action) {
      return function (ctx, next) {
        let modelId = ctx.params.model;
        let Model = models[modelId];
        if (!Model) {
          //404
          return next();
        }
        ctx.state.Model = Model;
        let middlewares = [];
        if (ctx.params.id) {
          ctx.state.id = ctx.params.id;
        }
  
        // api 目录下定义的中间件
        if (apis[modelId] && apis[modelId][action]) {
          middlewares.push(apis[modelId][action]);
        }
  
        // Model.api参数定义的中间件
        if (Model.api && Model.api[action]) {
          middlewares.push(defaultApiController[action]);
        }
        //console.log(middlewares);
  
        if (!middlewares.length) {
          //404
          return next();
        }
        return (0, _koaCompose2.default)(middlewares)(ctx, next);
      };
    }
docs: 注册某个类型API