Giter Site home page Giter Site logo

Comments (22)

sixlettervariables avatar sixlettervariables commented on August 10, 2024

+1 (I'd use this feature today)

from express-enrouten.

jasisk avatar jasisk commented on August 10, 2024

So the complexity here is that enrouten has no concept of config. Thinking this over, I think the simplest way to implement this would be to add another internal shortstop handler to confit—similar to the config handler—that would be replaced with a reference to the completely built config factory. That way, it could be passed as an argument (or option) to enrouten.

Just a thought.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

Yeah. Some sort of opaque thing passed in? If it's config, yay! when used by Kraken.

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

Yep, this is a long time coming but really is a form of DI. As I start contemplating I welcome any thoughts or ideas.

EDIT: And yes, I'll start digging into your suggestion @jasisk.

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

One thing that just occurred to me is that this will necessarily force a major version change (I was hoping it wouldn't). The current rule for directory mode is that the traversal mechanism will only initialize files that accept a single argument, allowing route definitions to be intermingled with other files. By having user-defined arguments the mechanism for identifying those files becomes much more murky.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

Oh, that is just unfortunate!

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

It may be a blessing in disguise. Gives us a little more latitude to take advantage of better directory layout and improve config. I've put together a very rough proposal if anyone has feedback.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

Aye. That seems like an awful lot of DI machinery and jargon to drag in, and it means that we're coupled to doing dependency injection our way, which just makes it unpleasant for people who have another opinion there.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

I see the intent, but something is rubbing me really wrong about it.

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

Yep, re: DI. I was considering using an existing implementation by default and injecting the router itself that way, but I haven't yet found a "lightweight" module, hence the code I put together. If we go through with this I'd prefer to defer to an existing module should we go in whole hog, and use it to manage all dependencies, including router.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

I dunno. It feels a lot like a lot of conceptual overhead to use an otherwise simple module.

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

I'm im not sure that simplicity and configurability are mutually exclusive. The request to inject arbitrary objects during initialization isn't the basic, simple use-case here. A smart default of always injecting the router will most certainly help.

from express-enrouten.

aredridel avatar aredridel commented on August 10, 2024

Indeed.

from express-enrouten.

grawk avatar grawk commented on August 10, 2024

regarding the single argument function, just because a function signature has a single argument doesn't mean the function cannot be called with additional arguments

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

True, but I'm personally not willing to codifyvar myvar = arguments[1]; as a desired pattern. :)

from express-enrouten.

grawk avatar grawk commented on August 10, 2024

What about attaching the config as a property of the router?

from express-enrouten.

jasisk avatar jasisk commented on August 10, 2024

That's interesting. We already provide a facade there.

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

Well attaching config explicitly so will create a tight coupling between kraken-js and enrouten, something that I'm trying to avoid. The only way to avoid that would be to support something like an additionalProperties config property that would be an object of arbitrary stuff which would get attached to the router instance.

With a design that supports multiple arguments the default case (just router) could possibly keep the current scanning mechanism, but when additional dependencies are configured to be injected it could switch into a more liberal scanning mode. That would preserve backward compat.

from express-enrouten.

grawk avatar grawk commented on August 10, 2024

the single argument could be an object but the user would need to be aware of when they have triggered DI in order to pull the router argument apart

from express-enrouten.

pvenkatakrishnan avatar pvenkatakrishnan commented on August 10, 2024

+1 to adding additional params as a config

from express-enrouten.

totherik avatar totherik commented on August 10, 2024

Does someone want to put together a proposal?

from express-enrouten.

grawk avatar grawk commented on August 10, 2024

I don't have much time today and tomorrow. But if it's still dangling when I'm free I would like to take a crack at it.

from express-enrouten.

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.