From bc7c03704f09623cc40160e3150769a42ca534b8 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 --- docs/CONTRIBUTING.md | 2 +- packages/cli/src/routeGeneration/templates/express.hbs | 2 +- packages/cli/src/routeGeneration/templates/hapi.hbs | 2 +- packages/cli/src/routeGeneration/templates/koa.hbs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 4fc759af8..1be68da80 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -36,7 +36,7 @@ In situations where the code is very hard to extend, we may want to refactor mod ## Contributing bug fixes Your pull request should include a link to the bug that you are fixing. If you've submitted a PR for a bug, please post a comment in the bug to avoid duplication of effort. - + ## Contributing features Features (things that add new or improved functionality to tsoa) may be accepted, but will need to **first** be approved by having the (["help wanted" label](https://github.com/lukeautry/tsoa/issues?q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) by a tsoa project maintainer) in the suggestion issue. 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; }