config 妙用

import MyConfig from "../appConfig";

export default (appInfo: EggAppInfo) => {
  const config = {} as DefaultConfig;

  Object.assign(config, MyConfig);

  return config;
};
1
2
3
4
5
6
7
8
9

使用

import { Provide, Config, ALL } from "@midwayjs/decorator";

@Provide()
export class ContentPathMiddleware implements IWebMiddleware {
  @Config(ALL)
  config: MyConfigType;
}
1
2
3
4
5
6
7