Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

await or return missing on promiseHandler in express.hbs template #1506

Closed
2 of 4 tasks
davidsaslawsky-trackinsight opened this issue Nov 7, 2023 · 2 comments
Closed
2 of 4 tasks
Labels

Comments

@davidsaslawsky-trackinsight

promiseHandler() returns a promise and should have either an await or a return here: https://github.com/lukeautry/tsoa/blob/master/packages/cli/src/routeGeneration/templates/express.hbs#L103C15-L103C29

The other templates (koa, hapi) are fine. I think it works on Express because it relies on the methods on the response object rather than on the end of the async handler.

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

Current Behavior

It works as expected now but the code is a bit unsafe.

Possible Solution

- promiseHandler(controller, promise, response, {{successStatus}}, next);
+ return promiseHandler(controller, promise, response, {{successStatus}}, next);

or maybe replace promiseHandler() by an await on the controller method: there's the try / catch block calling next(err) anyway.

Context (Environment)

Version of the library: 5.1.1
Version of NodeJS: Node 18

  • Confirm you were using yarn not npm: [ x]
Copy link

github-actions bot commented Nov 7, 2023

Hello there davidsaslawsky-trackinsight 👋

Thank you for opening your very first issue in this project.

We will try to get back to you as soon as we can.👀

Copy link

github-actions bot commented Dec 8, 2023

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant