-
Notifications
You must be signed in to change notification settings - Fork 10
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
Class based HttpService prevents inclusion of useAuth values for ky 'interceptor' hooks #2
Comments
Hi! Thanks for the suggestion. At this moment I don't have too much time for developing this template. I added your request/suggestion to my to-do list. If there will be an update about it I will let you know ASAP! :) |
@tommyderami by chance did you have time to complete the useHttpService hook fork? That sounds like a good use case! |
Hi! Thanks for the feedback. In the beginning, I would like to clarify that I was developing this template with reusability and lib-agnosticism in the first place. There are many authentication providers and strategies and it's fairly difficult to predict at this stage which implementation of httpService would be the most generic and best option for all. That's why a simple solution in the form of HttpService class was provided as the basic element for further extensions. Personally, I didn't have time and a need for preparing a more advanced facade that could be integrated with external hooks. For instance, you may always include a token or whatever you need in the I would recommend playing with this HttpService class (transform it into a function or a hook) and correlated types in order to create the best DX for your project. You are also more than welcome to share with me your own ideas and solutions integrated with a specific auth provider inside your personal projects. They could eventually set an example of how this template could be even more flexible and reusable. I am also going to use this template in my future hobby projects as well and see how it works with more advanced projects where authentication is must-have and maybe it will be a driver for adapting existing httpService solution. Together, with specific examples and use cases, we could figure out the best option for fetching logic. I hope it makes sense to you. Best regards! |
Hey @bartstc this template has been a super helpful starting point with great structure and dependency choices. One improvement might be switching the HttpService class to a useHttpService hook with the header/host options set in the hook. This would allow the useAuth hooks to provide JWT/cookie/etc context to protected routes via their hooks API. If there isn't a strong security concern that prompted the private class elements it might make the HTTP service slightly more ergonomic. If you agree this would be a good change, I'm currently working on my own refactor that I can push as a PR if desired, although I'm sure you could write something much cleaner than my code!
The text was updated successfully, but these errors were encountered: