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

Async await support within use #28

Merged
merged 3 commits into from
Oct 9, 2017
Merged

Async await support within use #28

merged 3 commits into from
Oct 9, 2017

Conversation

mcollina
Copy link
Member

As titled

cc @allevo

@mcollina mcollina requested a review from delvedor September 29, 2017 16:17
@allevo
Copy link
Member

allevo commented Sep 29, 2017

I'd like to build a npm module to handle this automatically. Maybe this weekend I figure out how to do this. In this case, are you Interested in that npm?

@mcollina
Copy link
Member Author

this seems pretty custom, but I’ll be happy to see what the ecosystem offers.

Copy link
Member

@delvedor delvedor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@delvedor
Copy link
Member

IMHO what we should make very clear, is that use must be called synchronously.
For example the following should not be valid:

getStruff()
  .then(stuff => {
    app.use(stuff)
  })

We should be able to detect it and throw an error.
Or find a way to support it, but I don't like it so much, avvio should be used as single system to handle asynchronous bootstrap, we should discourage mixed approaches.

The above example for instance, should be like this:

app.use(async function (app, opts, next) {
  const stuff = await getStruff()
  app.use(stuff, next)
})

@mcollina
Copy link
Member Author

@delvedor can you please provide another (bigger) example? It seems that is working.

@allevo
Copy link
Member

allevo commented Oct 2, 2017

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

Successfully merging this pull request may close these issues.

3 participants