r/Fastify•
awpt1mus

How do you manage dependencies

I am coming from OOP framework like Nest.js to fastify. I want to know what is better approach to share dependencies.

For example in OOP, You have controller class injects service classes service classes inject repository classes

In fastify do I create classes and decorate fastify instance with those class instances or Keep the services as pure functions and receive everything via arguments?

I think keeping pure functions for utilities will make testing easier ? What do you guys generally follow. TIA

Posted Mar 4, 2025, 12:08 PM UTC

21

Comments aren't archived yet

This post had 1 comment on Reddit. Comments for this period haven't been loaded into the archive yet.