midwayjs / hooks

"Zero" Api / Type Safe / Fullstack Kit / Powerful Backend
MIT License
690 stars 63 forks source link

函数 api 无法使用 Guard #425

Open mengxiong10 opened 1 year ago

mengxiong10 commented 1 year ago

使用函数Api 只能把元数据设置到 runner,不能把元数据设置到 FunctionContainer 上里面, , 导致守卫函数里面获取不到元数据

@Guard()
export class AuthGuard implements IGuard<Context> {
  async canActivate(context: Context, FunctionContainer, methodName: string): Promise<boolean> {
     getPropertyMetadata<string[]>('key', FunctionContainer, methodName);
  }
}
Lxxyx commented 1 year ago

关于函数中 Guard 的用法我这边看看