(
instance: Controller,
callback: (...args: unknown[]) => void,
moduleKey: string,
methodName: string,
)
| 55 | ) {} |
| 56 | |
| 57 | public create<T extends ParamsMetadata = ParamsMetadata>( |
| 58 | instance: Controller, |
| 59 | callback: (...args: unknown[]) => void, |
| 60 | moduleKey: string, |
| 61 | methodName: string, |
| 62 | ): (...args: any[]) => Promise<void> { |
| 63 | const contextType: ContextType = 'ws'; |
| 64 | const { argsLength, paramtypes, getParamsMetadata } = this.getMetadata<T>( |
| 65 | instance, |
| 66 | methodName, |
| 67 | contextType, |
| 68 | ); |
| 69 | const exceptionHandler = this.exceptionFiltersContext.create( |
| 70 | instance, |
| 71 | callback, |
| 72 | moduleKey, |
| 73 | ); |
| 74 | const pipes = this.pipesContextCreator.create( |
| 75 | instance, |
| 76 | callback, |
| 77 | moduleKey, |
| 78 | ); |
| 79 | const guards = this.guardsContextCreator.create( |
| 80 | instance, |
| 81 | callback, |
| 82 | moduleKey, |
| 83 | ); |
| 84 | const interceptors = this.interceptorsContextCreator.create( |
| 85 | instance, |
| 86 | callback, |
| 87 | moduleKey, |
| 88 | ); |
| 89 | |
| 90 | const paramsMetadata = getParamsMetadata(moduleKey); |
| 91 | const paramsOptions = paramsMetadata |
| 92 | ? this.contextUtils.mergeParamsMetatypes(paramsMetadata, paramtypes) |
| 93 | : []; |
| 94 | const fnApplyPipes = this.createPipesFn(pipes, paramsOptions); |
| 95 | |
| 96 | const fnCanActivate = this.createGuardsFn( |
| 97 | guards, |
| 98 | instance, |
| 99 | callback, |
| 100 | contextType, |
| 101 | ); |
| 102 | |
| 103 | const handler = (initialArgs: unknown[], args: unknown[]) => async () => { |
| 104 | if (fnApplyPipes) { |
| 105 | await fnApplyPipes(initialArgs, ...args); |
| 106 | return callback.apply(instance, initialArgs); |
| 107 | } |
| 108 | return callback.apply(instance, args); |
| 109 | }; |
| 110 | const targetPattern = this.reflectCallbackPattern(callback); |
| 111 | return this.wsProxy.create( |
| 112 | async (...args: unknown[]) => { |
| 113 | args.push(targetPattern); |
| 114 |
nothing calls this directly
no test coverage detected