-
Notifications
You must be signed in to change notification settings - Fork 29
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
Can we support async middleware factories? #74
Comments
There are two pieces of complexity here. The first is minor and has to do with a bit of ambiguity. The current signature includes passing in an array of arguments. This signature would have to change to support a callback being programmatically appended. Not a huge deal but, off the top of my head, I cannot come up with a new signature that I like to support both. Love to hear if you have any thoughts. The second complexity is a bit of a doozy. Express has no concept of asynchronous middleware registration. If you take a peek at how express registers functions into the continuation, it's wholly synchronous. The way things work right now, the moment you register In other words, |
As for how you can accomplish this already: The |
Oh wow, haven't thought of that, good point 😄 |
Sure. Let me know if an example or two would help. 😀 |
@jasisk I wouldn't mind seeing a couple of examples |
Hey,
Assuming this is our config:
And this is
foo.js
:As you can see,
makeMiddleware
is an asynchronous function, which yields to a callback. This can happen because sometime middleware initialization can do async stuff (like reading from a config file, database, etc.). Unfortunately, from looking at the docs and code, it seems that there is no support for async middleware factories, so the code above will fail.Can we add support for that? 😄
The text was updated successfully, but these errors were encountered: