Skip to content

内置中间件

全局中间件

名称说明
a-core:gate可以让API在指定的运行环境生效

系统中间件

名称说明
a-core:notfound404
a-core:overrideMethod
a-instance:appReady初始化app对象
a-instance:instance初始化instance对象
a-logger:httpLog输出日志
a-security:corsCORS
a-security:securitiesSecurities
a-static:static处理静态资源

a-core:gate

可以让 API 在指定的运行环境生效

名称类型说明
flavorstring|string[]参见: 运行环境与Flavor
modestring|string[]参见: 运行环境与Flavor
instanceNamestring|string[]参见: 多实例/多租户
hoststring|string[]主机名
  • 一般用法:
typescript
import { Aspect } from 'vona-module-a-aspect';

@Aspect.middlewareGlobal('a-core:gate', {
  gate: {
    flavor: 'normal',
    mode: 'dev',
    instanceName: '',
    host: 'localhost:7102',
  },
})
  • 简写方式:
typescript
import { Core } from 'vona-module-a-core';

@Core.gate({
  gate: {
    flavor: 'normal',
    mode: 'dev',
    instanceName: '',
    host: 'localhost:7102',
  },
})
  • 简写原理:

@Core.gate内部仍然调用的是@Aspect.middlewareGlobal,代码如下:

typescript
function Gate(
  options?: Partial<TypeUseOnionOmitOptionsGlobal<IMiddlewareOptionsGate>>,
): ClassDecorator & MethodDecorator {
  return Aspect.middlewareGlobal('a-core:gate', options);
}

基于 MIT 许可发布