-
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
Add dependancy injection for handlers #230
Comments
@Isaac-Leonard , for me this method looks redundant, since you're connecting this In case this entity somehow depends on incoming data or available for limited users, the existing method Perhaps I'm missing something. Please let me know if these two solutions are not suitable for your case (with some more details). Thank you! |
Actually yeah you're right, I really should read the full documentation first before trying to add features.bThe only differences I would maybe make is to add the properties on options directly to the argument passed to handler instead of as a options property but really that doesn't make much of a difference and not requiring the createMiddleware boilerplate.. |
Actually no |
I agree, that in some cases, especially for empty inputs, there may be some sort of shorthand for providing Endpoints with options easier. Need to think on it a little bit... |
@Isaac-Leonard , please check out PR #234. |
Currently the package provides a logger in a sort of DI way which is extremely useful.
I believe it should be possible to generalise this so users could add their own dependancy objects to pass to handlers when building endpoints.
I've got some code that can sort of do this already however it is not perfect yet and would be a breaking change when it shouldn't be so not ready for a pull request yet.
An example usage would be
Sorry for any mistakes, its 04:00 am here.
What do you think of this?
I'd also like to expand it to add dependancies that get created with a function on each request too for stuff like specific database connections instead of a single database object.
The text was updated successfully, but these errors were encountered: