Show HN: Backhooks, hooks for Node.js and the back-end
1–10 of 10 posts
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#2Re: Show HN: Backhooks, hooks for Node.js and the back-end
#3Re: Show HN: Backhooks, hooks for Node.js and the back-end
#4is this... Dependency Injection and function calls?
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#5This is so interesting! Could you explain to me, as if I were new to all these… let’s say, and considering web hooks as a comparable knowledge gap.. what’s a backhook and how can it be used!!?
A backhook is basically a function that knows from where it has been called. It means that it holds some state bound to a specific context.
This has many advantages:
- Better typing: Today, most of the context bindings are made by attaching new properties to a request object. That makes typing complicated and not reliable. When using backhooks, your typing is always accurate.
- Easier APIs: If you're a library developer, and want to provide a function that relies on headers for a function, you can write it without taking the headers as parameters and instead use other hooks to retrieve it. It simplifies everyone's life.
- They are many ways to use backhooks, from retrieving the authenticated user in the current context to aggregate logs with a requestId to make it easy to trace them.
I'll be happy to response to any other questions! Thanks for taking the time to comment.
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#6This is so interesting! Could you explain to me, as if I were new to all these… let’s say, and considering web hooks as a comparable knowledge gap.. what’s a backhook and how can it be used!!?
Hey! Thanks for the interaction! I'll try to make it simple: A backhook is basically a function that knows from where it has been called. It means that it holds some state bound to a specific context. This has many advantages: - Better typing: Today, most of the context bindings are made by attaching new properties to a request object. That makes typing complicated and not reliable. When using backhooks, your typing…
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#7Earlier quoted context omitted.
Hey! Thanks for the interaction! I'll try to make it simple: A backhook is basically a function that knows from where it has been called. It means that it holds some state bound to a specific context. This has many advantages: - Better typing: Today, most of the context bindings are made by attaching new properties to a request object. That makes typing complicated and not reliable. When using backhooks, your typing…
Really nice work, thanks! Much cleaner than pulling arbitrary properties off the HTTP request context, and gets a nice conceptual leg-up by analogy to React hooks.
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#8I'll have to try this out on my next project! It seems like it will save me from writing a bunch of ugly boilerplate in express routes. One more GH star from me!
Re: Show HN: Backhooks, hooks for Node.js and the back-end
#9This seems really powerful. Nice job! React hooks get a lot of hate, but now that I've spent a couple years with them, I like the modularity and composability of them. This feels familiar in that regard. I'll have to try this out on my next project! It seems like it will save me from writing a bunch of ugly boilerplate in express routes. One more GH star from me!