| 2363 | |
| 2364 | async execute<T>( |
| 2365 | input: T, |
| 2366 | finalHandler: (input: T, token?: AbortToken) => Promise<any>, |
| 2367 | token?: AbortToken, |
| 2368 | ): Promise<any> { |
| 2369 | const exec = async ( |
| 2370 | idx: number, |
| 2371 | curInput: T, |
| 2372 | curToken?: AbortToken, |
| 2373 | ): Promise<any> => { |
| 2374 | if (idx >= this.middlewares.length) |
| 2375 | return await finalHandler(curInput, curToken); |
| 2376 | const mw = this.middlewares[idx]; |
| 2377 | return await mw.process( |
| 2378 | curInput, |
| 2379 | (nextInput, nextToken) => exec(idx + 1, nextInput, nextToken), |
| 2380 | curToken, |
| 2381 | ); |
| 2382 | }; |
| 2383 | return await exec(0, input, token); |
| 2384 | } |
| 2385 | } |
| 2386 | |
| 2387 | class TimeoutMiddleware implements Middleware { |
| 2388 | private configManagerPromise: Promise<ConfigManager>; |