From 55059f3cfba6c30006074ff23e4bf848a7e8d7b5 Mon Sep 17 00:00:00 2001 From: lokmeinmatz Date: Sat, 22 Oct 2022 01:42:21 +0200 Subject: [PATCH] Fix vitest esm error with @Security guard Without this change, using vitest with "esm": true for routes config and an @Security guarded endpoint led to an error "... is not a constructor" or infinite running tests. Bug related to https://github.com/es-shims/Promise.allSettled/issues/5#issuecomment-747464536 --- packages/cli/src/routeGeneration/templates/express.hbs | 2 +- packages/cli/src/routeGeneration/templates/hapi.hbs | 2 +- packages/cli/src/routeGeneration/templates/koa.hbs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/cli/src/routeGeneration/templates/express.hbs b/packages/cli/src/routeGeneration/templates/express.hbs index eefc2dc1d..b0818f67f 100644 --- a/packages/cli/src/routeGeneration/templates/express.hbs +++ b/packages/cli/src/routeGeneration/templates/express.hbs @@ -164,7 +164,7 @@ export function RegisterRoutes(app: express.Router) { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa try { - request['user'] = await promiseAny(secMethodOrPromises); + request['user'] = await promiseAny.call(Promise, secMethodOrPromises); next(); } catch(err) { diff --git a/packages/cli/src/routeGeneration/templates/hapi.hbs b/packages/cli/src/routeGeneration/templates/hapi.hbs index 98faac467..a49843c98 100644 --- a/packages/cli/src/routeGeneration/templates/hapi.hbs +++ b/packages/cli/src/routeGeneration/templates/hapi.hbs @@ -190,7 +190,7 @@ export function RegisterRoutes(server: any) { // WARNING: This file was auto-generated with tsoa. Please do not modify it. Re-run tsoa to re-generate this file: https://github.com/lukeautry/tsoa try { - request['user'] = await promiseAny(secMethodOrPromises); + request['user'] = await promiseAny.call(Promise, secMethodOrPromises); return request['user']; } catch(err) { diff --git a/packages/cli/src/routeGeneration/templates/koa.hbs b/packages/cli/src/routeGeneration/templates/koa.hbs index 3baf88257..62136a98e 100644 --- a/packages/cli/src/routeGeneration/templates/koa.hbs +++ b/packages/cli/src/routeGeneration/templates/koa.hbs @@ -160,7 +160,7 @@ export function RegisterRoutes(router: KoaRouter) { let success; try { - const user = await promiseAny(secMethodOrPromises); + const user = await promiseAny.call(Promise, secMethodOrPromises); success = true; context.request['user'] = user; }