Comments (5)
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 meddleware
into your app, everything else done by meddleware happens synchronously. This means that the order of middleware registration is predictable. Introducing async resolution into a pipeline that has no concept of async would mean registration order would no longer be predictable.
In other words, app.use(meddleware(config), otherMiddleware)
could result in otherMiddleware
being before, after, or somewhere in the middle of meddleware
-defined middlewares.
from meddleware.
As for how you can accomplish this already:
The meddleware
config can be resolved asynchronously, which would then be passed to meddleware. This is exactly how kraken uses it. To perform a similar action in kraken, you could perform your various async steps in the onconfig
method you can pass into the kraken config. You could then set the values resulted by the async steps into the config as middleware arguments.
from meddleware.
Oh wow, haven't thought of that, good point 😄
I guess I can try to use onconfig
for now.
Thanks!
from meddleware.
Sure. Let me know if an example or two would help. 😀
from meddleware.
@jasisk I wouldn't mind seeing a couple of examples
from meddleware.
Related Issues (20)
- Route on middleware not working HOT 6
- Backport route regex support for v1.x?
- Events not fired properly HOT 5
- normalize the config `module` property
- add array support for the `route` property HOT 1
- `mountpath` isn't always a string HOT 4
- Enabled toggle in flow controlled sections changed HOT 3
- `util#mapValues` `prop.name` won't ever exist
- `module.name` is not required? HOT 1
- Meddleware 4.0 not working as expected HOT 9
- Passing object to middleware HOT 1
- Register middleware based on HTTP method HOT 3
- Deprecate RQ for parallelism HOT 1
- Why is the configuration an object instead of an array of objects?
- edge case bug in the local path resolver HOT 1
- npm5 issue HOT 1
- How can I have an environment-controllable value that defaults to true? HOT 3
- meddleware broken with config v.3.0
- if modulePath is undefined, the require might resolve relative path from config wrongly HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meddleware.