News for hackers. Stuff that matters.

codehammer

Re:On-Demand Docker Containers with Node.js on Saturday March 01, 2025 @08:23PM (#43226114)
Have you ever wondered how Google Cloud Run magically scales your services down to zero and still manages to respond to incoming requests instantly? Let’s try to mimic that feature with NodeJS
Re:Show HN: Backhooks, hooks for Node.js and the back-end on Thursday January 19, 2023 @03:01AM (#34437846)
Hey thank you for your nice feedback! I would be happy to hear your experience with it, don't hesitate to open an issue or a discussion in github if you have any question or feedback as a user!
Re:Show HN: Backhooks, hooks for Node.js and the back-end on Thursday January 19, 2023 @02:31AM (#34437673)
Thank you for the nice feedback!
Re:Show HN: Backhooks, hooks for Node.js and the back-end on Thursday January 19, 2023 @01:29AM (#34437339)
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 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 on Thursday January 19, 2023 @01:18AM (#34437292)
It is actually! Dependency injection is not that easy with NodeJS in some execution contexts like http requests. Some frameworks make it easy like NestJS, but it's a relatively heavy implementation of DI. This method is lightweight and potentially easier to use, with an API close to react hooks or vue composables. Thanks for commenting!