Git Product home page Git Product logo

Comments (5)

jasisk avatar jasisk commented on June 24, 2024

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.

jasisk avatar jasisk commented on June 24, 2024

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.

giladgo avatar giladgo commented on June 24, 2024

Oh wow, haven't thought of that, good point 😄
I guess I can try to use onconfig for now.
Thanks!

from meddleware.

jasisk avatar jasisk commented on June 24, 2024

Sure. Let me know if an example or two would help. 😀

from meddleware.

jknight12882 avatar jknight12882 commented on June 24, 2024

@jasisk I wouldn't mind seeing a couple of examples

from meddleware.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.